mattermost-mobile/app/client/rest/error.ts
Felipe Martin 432cfb08fe
feat: show pre-auth secret error on field on server create (#9102)
* feat: show potential pre-auth secret error on server create

* chroe: address comments

* chore: updated message

* feat: read response header to check error source

* fix: i18n

* chore: rename pre-auth to just auth
2025-09-17 08:04:28 +02:00

28 lines
1 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {cleanUrlForLogging} from '@utils/url';
export default class ClientError extends Error {
url: string;
intl?: ClientErrorIntl;
server_error_id?: string;
status_code?: number;
details?: unknown;
headers?: Record<string, string>;
constructor(baseUrl: string, data: ClientErrorProps) {
super(data.message + ': ' + cleanUrlForLogging(baseUrl, data.url));
this.message = data.message;
this.url = data.url;
this.intl = data.intl;
this.server_error_id = data.server_error_id;
this.status_code = data.status_code;
this.details = data.details;
this.headers = data.headers;
// Ensure message is treated as a property of this class when object spreading. Without this,
// copying the object by using `{...error}` would not include the message.
Object.defineProperty(this, 'message', {enumerable: true});
}
}