1 |
|
2 | export class MTError extends Error {
|
3 | static getMessage(code, type, message) {
|
4 | return `MT[${code}] ${type}: ${message}`;
|
5 | }
|
6 | constructor(code, type, message) {
|
7 | const fullMessage = MTError.getMessage(code, type, message);
|
8 | super(fullMessage);
|
9 | this.code = code;
|
10 | this.type = type;
|
11 | }
|
12 | }
|
13 |
|
14 | export class ErrorBadResponse extends MTError {
|
15 | constructor(url, originalError = null) {
|
16 | super(406, 'NETWORK_BAD_RESPONSE', url);
|
17 | if (originalError) this.originalError = originalError;
|
18 | }
|
19 | }
|
20 |
|
21 | export class ErrorNotFound extends MTError {
|
22 | constructor(err) {
|
23 | super(404, 'REQUEST_FAILED', err.config.url);
|
24 | this.originalError = err;
|
25 | }
|
26 | }
|
27 |
|
\ | No newline at end of file |