@bombillazo/error-x 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +235 -370
- package/dist/index.cjs +501 -593
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +580 -675
- package/dist/index.d.ts +580 -675
- package/dist/index.js +501 -593
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9,16 +9,6 @@ var safeStringify__default = /*#__PURE__*/_interopDefault(safeStringify);
|
|
|
9
9
|
// src/error.ts
|
|
10
10
|
|
|
11
11
|
// src/types.ts
|
|
12
|
-
var HandlingTargets = /* @__PURE__ */ ((HandlingTargets2) => {
|
|
13
|
-
HandlingTargets2["MODAL"] = "modal";
|
|
14
|
-
HandlingTargets2["TOAST"] = "toast";
|
|
15
|
-
HandlingTargets2["INLINE"] = "inline";
|
|
16
|
-
HandlingTargets2["BANNER"] = "banner";
|
|
17
|
-
HandlingTargets2["CONSOLE"] = "console";
|
|
18
|
-
HandlingTargets2["LOGGER"] = "logger";
|
|
19
|
-
HandlingTargets2["NOTIFICATION"] = "notification";
|
|
20
|
-
return HandlingTargets2;
|
|
21
|
-
})(HandlingTargets || {});
|
|
22
12
|
var ERROR_X_OPTION_FIELDS = [
|
|
23
13
|
"message",
|
|
24
14
|
"name",
|
|
@@ -26,14 +16,18 @@ var ERROR_X_OPTION_FIELDS = [
|
|
|
26
16
|
"uiMessage",
|
|
27
17
|
"cause",
|
|
28
18
|
"metadata",
|
|
29
|
-
"actions",
|
|
30
19
|
"httpStatus",
|
|
31
|
-
"type"
|
|
20
|
+
"type",
|
|
21
|
+
"sourceUrl",
|
|
22
|
+
"docsUrl",
|
|
23
|
+
"source"
|
|
32
24
|
];
|
|
33
25
|
|
|
34
26
|
// src/error.ts
|
|
35
27
|
var acceptedFields = new Set(ERROR_X_OPTION_FIELDS);
|
|
36
28
|
var ErrorX = class _ErrorX extends Error {
|
|
29
|
+
/** Global configuration for all ErrorX instances */
|
|
30
|
+
static _config = null;
|
|
37
31
|
/** Error identifier code, auto-generated from name if not provided */
|
|
38
32
|
code;
|
|
39
33
|
/** User-friendly message suitable for display in UI */
|
|
@@ -42,71 +36,87 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
42
36
|
metadata;
|
|
43
37
|
/** Timestamp when the error was created */
|
|
44
38
|
timestamp;
|
|
45
|
-
/** Error actions for UI behavior and handling */
|
|
46
|
-
actions;
|
|
47
39
|
/** HTTP status code (100-599) for HTTP-related errors */
|
|
48
40
|
httpStatus;
|
|
49
41
|
/** Error type for categorization */
|
|
50
42
|
type;
|
|
43
|
+
/** Source URL related to the error (API endpoint, page URL, resource URL) */
|
|
44
|
+
sourceUrl;
|
|
45
|
+
/** Documentation URL for this specific error */
|
|
46
|
+
docsUrl;
|
|
47
|
+
/** Where the error originated (service name, module, component) */
|
|
48
|
+
source;
|
|
51
49
|
/**
|
|
52
50
|
* Creates a new ErrorX instance with enhanced error handling capabilities.
|
|
53
51
|
*
|
|
54
|
-
* @param messageOrOptions - Error message string
|
|
55
|
-
* @param additionalOptions - Additional options when first parameter is a string (optional)
|
|
52
|
+
* @param messageOrOptions - Error message string or ErrorXOptions object (optional)
|
|
56
53
|
*
|
|
57
54
|
* @example
|
|
58
55
|
* ```typescript
|
|
56
|
+
* // Create with default message
|
|
57
|
+
* const error1 = new ErrorX()
|
|
58
|
+
*
|
|
59
59
|
* // Create with string message only
|
|
60
|
-
* const
|
|
60
|
+
* const error2 = new ErrorX('Database query failed')
|
|
61
61
|
*
|
|
62
|
-
* // Create with
|
|
63
|
-
* const
|
|
62
|
+
* // Create with options object
|
|
63
|
+
* const error3 = new ErrorX({
|
|
64
|
+
* message: 'Database query failed',
|
|
64
65
|
* name: 'DatabaseError',
|
|
65
66
|
* code: 'DB_QUERY_FAILED',
|
|
66
67
|
* uiMessage: 'Unable to load data. Please try again.',
|
|
67
68
|
* metadata: { query: 'SELECT * FROM users', timeout: 5000 }
|
|
68
69
|
* })
|
|
69
70
|
*
|
|
70
|
-
* //
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* actions: [
|
|
76
|
-
* { action: 'notify', payload: { targets: [HandlingTargets.TOAST] } }
|
|
77
|
-
* ]
|
|
71
|
+
* // With type-safe metadata
|
|
72
|
+
* type MyMeta = { userId: number };
|
|
73
|
+
* const error4 = new ErrorX<MyMeta>({
|
|
74
|
+
* message: 'User action failed',
|
|
75
|
+
* metadata: { userId: 123 }
|
|
78
76
|
* })
|
|
79
77
|
*
|
|
80
|
-
* //
|
|
78
|
+
* // For converting unknown errors, use ErrorX.from()
|
|
81
79
|
* const apiError = { message: 'User not found', code: 404 }
|
|
82
|
-
* const
|
|
83
|
-
*
|
|
84
|
-
* // Create with no options (uses defaults)
|
|
85
|
-
* const error5 = new ErrorX()
|
|
80
|
+
* const error5 = ErrorX.from(apiError)
|
|
86
81
|
* ```
|
|
87
82
|
*/
|
|
88
|
-
constructor(messageOrOptions
|
|
83
|
+
constructor(messageOrOptions) {
|
|
89
84
|
let options = {};
|
|
90
85
|
if (typeof messageOrOptions === "string") {
|
|
91
|
-
options = {
|
|
92
|
-
message: messageOrOptions,
|
|
93
|
-
...additionalOptions
|
|
94
|
-
};
|
|
95
|
-
} else if (_ErrorX.isErrorXOptions(messageOrOptions)) {
|
|
96
|
-
options = messageOrOptions;
|
|
86
|
+
options = { message: messageOrOptions };
|
|
97
87
|
} else if (messageOrOptions != null) {
|
|
98
|
-
options =
|
|
88
|
+
options = messageOrOptions;
|
|
89
|
+
}
|
|
90
|
+
const envConfig = _ErrorX.getConfig();
|
|
91
|
+
const message = options.message?.trim() ? options.message : "An error occurred";
|
|
92
|
+
super(message, { cause: options.cause });
|
|
93
|
+
if (options.cause !== void 0 && !Object.hasOwn(this, "cause")) {
|
|
94
|
+
Object.defineProperty(this, "cause", {
|
|
95
|
+
value: options.cause,
|
|
96
|
+
writable: true,
|
|
97
|
+
enumerable: false,
|
|
98
|
+
configurable: true
|
|
99
|
+
});
|
|
99
100
|
}
|
|
100
|
-
const formattedMessage = _ErrorX.formatMessage(options.message);
|
|
101
|
-
super(formattedMessage, { cause: options.cause });
|
|
102
101
|
this.name = options.name ?? _ErrorX.getDefaultName();
|
|
103
102
|
this.code = options.code != null ? String(options.code) : _ErrorX.generateDefaultCode(options.name);
|
|
104
103
|
this.uiMessage = options.uiMessage;
|
|
105
104
|
this.metadata = options.metadata;
|
|
106
|
-
this.actions = options.actions;
|
|
107
105
|
this.httpStatus = _ErrorX.validateHttpStatus(options.httpStatus);
|
|
108
106
|
this.type = _ErrorX.validateType(options.type);
|
|
109
107
|
this.timestamp = /* @__PURE__ */ new Date();
|
|
108
|
+
this.sourceUrl = options.sourceUrl;
|
|
109
|
+
this.source = options.source ?? envConfig?.source;
|
|
110
|
+
let generatedDocsUrl;
|
|
111
|
+
if (envConfig?.docsBaseURL && envConfig?.docsMap && this.code) {
|
|
112
|
+
const docPath = envConfig.docsMap[this.code];
|
|
113
|
+
if (docPath) {
|
|
114
|
+
const base = envConfig.docsBaseURL.replace(/\/+$/, "");
|
|
115
|
+
const path = docPath.replace(/^\/+/, "");
|
|
116
|
+
generatedDocsUrl = `${base}/${path}`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.docsUrl = options.docsUrl ?? generatedDocsUrl;
|
|
110
120
|
if (options.cause instanceof Error) {
|
|
111
121
|
this.stack = _ErrorX.preserveOriginalStack(options.cause, this);
|
|
112
122
|
} else {
|
|
@@ -123,6 +133,34 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
123
133
|
static getDefaultName() {
|
|
124
134
|
return "Error";
|
|
125
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Configure global ErrorX settings.
|
|
138
|
+
* This method allows you to set defaults for all ErrorX instances.
|
|
139
|
+
*
|
|
140
|
+
* @param config - Configuration object
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* ErrorX.configure({
|
|
145
|
+
* source: 'my-api-service',
|
|
146
|
+
* docsBaseURL: 'https://docs.example.com/errors',
|
|
147
|
+
* docsMap: {
|
|
148
|
+
* 'AUTH_FAILED': 'authentication-errors',
|
|
149
|
+
* 'DB_ERROR': 'database-errors'
|
|
150
|
+
* }
|
|
151
|
+
* })
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
static configure(config) {
|
|
155
|
+
_ErrorX._config = { ..._ErrorX._config || {}, ...config };
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get the current global configuration.
|
|
159
|
+
* Returns null if no configuration has been set.
|
|
160
|
+
*/
|
|
161
|
+
static getConfig() {
|
|
162
|
+
return _ErrorX._config;
|
|
163
|
+
}
|
|
126
164
|
/**
|
|
127
165
|
* Validates HTTP status code to ensure it's within valid range (100-599)
|
|
128
166
|
*
|
|
@@ -218,10 +256,24 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
218
256
|
*/
|
|
219
257
|
static cleanStack(stack) {
|
|
220
258
|
if (!stack) return "";
|
|
259
|
+
const config = _ErrorX.getConfig();
|
|
260
|
+
const cleanStackConfig = config?.cleanStack ?? true;
|
|
261
|
+
if (cleanStackConfig === false) {
|
|
262
|
+
return stack;
|
|
263
|
+
}
|
|
221
264
|
const stackLines = stack.split("\n");
|
|
222
265
|
const cleanedLines = [];
|
|
266
|
+
const defaultPatterns = [
|
|
267
|
+
"new ErrorX",
|
|
268
|
+
"ErrorX.constructor",
|
|
269
|
+
"ErrorX.from",
|
|
270
|
+
"error-x/dist/",
|
|
271
|
+
"error-x/src/error.ts"
|
|
272
|
+
];
|
|
273
|
+
const patterns = Array.isArray(cleanStackConfig) ? cleanStackConfig : defaultPatterns;
|
|
223
274
|
for (const line of stackLines) {
|
|
224
|
-
|
|
275
|
+
const shouldSkip = patterns.some((pattern) => line.includes(pattern));
|
|
276
|
+
if (shouldSkip) {
|
|
225
277
|
continue;
|
|
226
278
|
}
|
|
227
279
|
cleanedLines.push(line);
|
|
@@ -251,35 +303,6 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
251
303
|
}
|
|
252
304
|
return stack;
|
|
253
305
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Formats error messages with proper capitalization and punctuation.
|
|
256
|
-
* Ensures consistent message formatting across all ErrorX instances.
|
|
257
|
-
*
|
|
258
|
-
* @param message - Raw error message to format (optional)
|
|
259
|
-
* @returns Formatted message with proper capitalization and punctuation
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* ```typescript
|
|
263
|
-
* formatMessage('database connection failed') // 'Database connection failed.'
|
|
264
|
-
* formatMessage('user not found. please check credentials') // 'User not found. Please check credentials.'
|
|
265
|
-
* formatMessage() // 'An error occurred'
|
|
266
|
-
* ```
|
|
267
|
-
*/
|
|
268
|
-
static formatMessage(message) {
|
|
269
|
-
if (!message || typeof message !== "string" || !message.trim()) {
|
|
270
|
-
return "An error occurred";
|
|
271
|
-
}
|
|
272
|
-
let formatted = message.split(". ").map((sentence) => {
|
|
273
|
-
const trimmed = sentence.trim();
|
|
274
|
-
if (!trimmed) return trimmed;
|
|
275
|
-
return trimmed.charAt(0).toUpperCase() + trimmed.slice(1);
|
|
276
|
-
}).join(". ");
|
|
277
|
-
const endsWithPunctuation = /[.!?)\]]$/.test(formatted);
|
|
278
|
-
if (!endsWithPunctuation) {
|
|
279
|
-
formatted = `${formatted}.`;
|
|
280
|
-
}
|
|
281
|
-
return formatted;
|
|
282
|
-
}
|
|
283
306
|
/**
|
|
284
307
|
* Creates a new ErrorX instance with additional metadata merged with existing metadata.
|
|
285
308
|
* The original error properties are preserved while extending the metadata.
|
|
@@ -310,15 +333,16 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
310
333
|
cause: this.cause,
|
|
311
334
|
metadata: { ...this.metadata ?? {}, ...additionalMetadata },
|
|
312
335
|
httpStatus: this.httpStatus,
|
|
313
|
-
type: this.type
|
|
336
|
+
type: this.type,
|
|
337
|
+
sourceUrl: this.sourceUrl,
|
|
338
|
+
docsUrl: this.docsUrl,
|
|
339
|
+
source: this.source
|
|
314
340
|
};
|
|
315
|
-
if (this.actions) {
|
|
316
|
-
options.actions = this.actions;
|
|
317
|
-
}
|
|
318
341
|
const newError = new _ErrorX(options);
|
|
319
342
|
if (this.stack) {
|
|
320
343
|
newError.stack = this.stack;
|
|
321
344
|
}
|
|
345
|
+
newError.timestamp = this.timestamp;
|
|
322
346
|
return newError;
|
|
323
347
|
}
|
|
324
348
|
/**
|
|
@@ -358,9 +382,11 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
358
382
|
let uiMessage = "";
|
|
359
383
|
let cause;
|
|
360
384
|
let metadata = {};
|
|
361
|
-
let actions;
|
|
362
385
|
let httpStatus;
|
|
363
386
|
let type;
|
|
387
|
+
let url;
|
|
388
|
+
let href;
|
|
389
|
+
let source;
|
|
364
390
|
if (error) {
|
|
365
391
|
if (typeof error === "string") {
|
|
366
392
|
message = error;
|
|
@@ -383,9 +409,6 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
383
409
|
if ("code" in error && error.code) code = String(error.code);
|
|
384
410
|
if ("uiMessage" in error && error.uiMessage) uiMessage = String(error.uiMessage);
|
|
385
411
|
else if ("userMessage" in error && error.userMessage) uiMessage = String(error.userMessage);
|
|
386
|
-
if ("actions" in error && Array.isArray(error.actions)) {
|
|
387
|
-
actions = error.actions;
|
|
388
|
-
}
|
|
389
412
|
let _httpStatus;
|
|
390
413
|
if ("httpStatus" in error) {
|
|
391
414
|
_httpStatus = error.httpStatus;
|
|
@@ -401,6 +424,25 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
401
424
|
if ("type" in error && error.type) {
|
|
402
425
|
type = _ErrorX.validateType(String(error.type));
|
|
403
426
|
}
|
|
427
|
+
if ("sourceUrl" in error && error.sourceUrl) {
|
|
428
|
+
url = String(error.sourceUrl);
|
|
429
|
+
} else if ("url" in error && error.url) {
|
|
430
|
+
url = String(error.url);
|
|
431
|
+
}
|
|
432
|
+
if ("docsUrl" in error && error.docsUrl) {
|
|
433
|
+
href = String(error.docsUrl);
|
|
434
|
+
} else if ("href" in error && error.href) {
|
|
435
|
+
href = String(error.href);
|
|
436
|
+
} else if ("documentationUrl" in error && error.documentationUrl) {
|
|
437
|
+
href = String(error.documentationUrl);
|
|
438
|
+
}
|
|
439
|
+
if ("source" in error && error.source) {
|
|
440
|
+
source = String(error.source);
|
|
441
|
+
} else if ("service" in error && error.service) {
|
|
442
|
+
source = String(error.service);
|
|
443
|
+
} else if ("component" in error && error.component) {
|
|
444
|
+
source = String(error.component);
|
|
445
|
+
}
|
|
404
446
|
metadata = { originalError: error };
|
|
405
447
|
}
|
|
406
448
|
}
|
|
@@ -412,58 +454,18 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
412
454
|
if (uiMessage) options.uiMessage = uiMessage;
|
|
413
455
|
if (cause) options.cause = cause;
|
|
414
456
|
if (Object.keys(metadata).length > 0) options.metadata = metadata;
|
|
415
|
-
if (actions && actions.length > 0) options.actions = actions;
|
|
416
457
|
if (httpStatus) options.httpStatus = httpStatus;
|
|
417
458
|
if (type) options.type = type;
|
|
459
|
+
if (url) options.sourceUrl = url;
|
|
460
|
+
if (href) options.docsUrl = href;
|
|
461
|
+
if (source) options.source = source;
|
|
418
462
|
return options;
|
|
419
463
|
}
|
|
420
|
-
|
|
421
|
-
* Converts unknown input into an ErrorX instance with intelligent property extraction.
|
|
422
|
-
* Handles strings, regular Error objects, API response objects, and unknown values.
|
|
423
|
-
*
|
|
424
|
-
* @param error - Value to convert to ErrorX
|
|
425
|
-
* @returns ErrorX instance with extracted properties
|
|
426
|
-
*
|
|
427
|
-
* @example
|
|
428
|
-
* ```typescript
|
|
429
|
-
* // Convert string error
|
|
430
|
-
* const error1 = ErrorX.toErrorX('Something went wrong')
|
|
431
|
-
*
|
|
432
|
-
* // Convert regular Error
|
|
433
|
-
* const error2 = ErrorX.toErrorX(new Error('Database failed'))
|
|
434
|
-
*
|
|
435
|
-
* // Convert API response object
|
|
436
|
-
* const apiError = {
|
|
437
|
-
* message: 'User not found',
|
|
438
|
-
* code: 'USER_404',
|
|
439
|
-
* statusText: 'Not Found'
|
|
440
|
-
* }
|
|
441
|
-
* const error3 = ErrorX.toErrorX(apiError)
|
|
442
|
-
* ```
|
|
443
|
-
*/
|
|
444
|
-
static toErrorX(error) {
|
|
464
|
+
static from(error) {
|
|
445
465
|
if (error instanceof _ErrorX) return error;
|
|
446
466
|
const options = _ErrorX.convertUnknownToOptions(error);
|
|
447
467
|
return new _ErrorX(options);
|
|
448
468
|
}
|
|
449
|
-
/**
|
|
450
|
-
* Public wrapper for processing error stack traces with delimiter.
|
|
451
|
-
* Delegates to the private processErrorStack method for implementation.
|
|
452
|
-
*
|
|
453
|
-
* @param error - Error whose stack to process
|
|
454
|
-
* @param delimiter - String to search for in stack lines
|
|
455
|
-
* @returns Processed stack trace starting after the delimiter
|
|
456
|
-
*
|
|
457
|
-
* @example
|
|
458
|
-
* ```typescript
|
|
459
|
-
* const error = new Error('Something failed')
|
|
460
|
-
* const cleanStack = ErrorX.processStack(error, 'my-app-entry')
|
|
461
|
-
* // Returns stack trace starting after the line containing 'my-app-entry'
|
|
462
|
-
* ```
|
|
463
|
-
*/
|
|
464
|
-
static processStack(error, delimiter) {
|
|
465
|
-
return _ErrorX.processErrorStack(error, delimiter);
|
|
466
|
-
}
|
|
467
469
|
/**
|
|
468
470
|
* Creates a new ErrorX instance with cleaned stack trace using the specified delimiter.
|
|
469
471
|
* Returns the same instance if no delimiter is provided or no stack is available.
|
|
@@ -487,14 +489,14 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
487
489
|
uiMessage: this.uiMessage,
|
|
488
490
|
cause: this.cause,
|
|
489
491
|
httpStatus: this.httpStatus,
|
|
490
|
-
type: this.type
|
|
492
|
+
type: this.type,
|
|
493
|
+
sourceUrl: this.sourceUrl,
|
|
494
|
+
docsUrl: this.docsUrl,
|
|
495
|
+
source: this.source
|
|
491
496
|
};
|
|
492
497
|
if (this.metadata !== void 0) {
|
|
493
498
|
options.metadata = this.metadata;
|
|
494
499
|
}
|
|
495
|
-
if (this.actions) {
|
|
496
|
-
options.actions = this.actions;
|
|
497
|
-
}
|
|
498
500
|
const newError = new _ErrorX(options);
|
|
499
501
|
newError.stack = _ErrorX.processErrorStack(this, delimiter);
|
|
500
502
|
return newError;
|
|
@@ -557,7 +559,10 @@ ${this.stack}`;
|
|
|
557
559
|
* ```
|
|
558
560
|
*/
|
|
559
561
|
toJSON() {
|
|
560
|
-
|
|
562
|
+
let safeMetadata;
|
|
563
|
+
if (this.metadata) {
|
|
564
|
+
safeMetadata = JSON.parse(safeStringify__default.default(this.metadata));
|
|
565
|
+
}
|
|
561
566
|
const serialized = {
|
|
562
567
|
name: this.name,
|
|
563
568
|
message: this.message,
|
|
@@ -566,35 +571,52 @@ ${this.stack}`;
|
|
|
566
571
|
metadata: safeMetadata,
|
|
567
572
|
timestamp: this.timestamp.toISOString()
|
|
568
573
|
};
|
|
569
|
-
if (this.actions && this.actions.length > 0) {
|
|
570
|
-
const stringified = safeStringify__default.default(this.actions);
|
|
571
|
-
serialized.actions = JSON.parse(stringified);
|
|
572
|
-
}
|
|
573
574
|
if (this.httpStatus !== void 0) {
|
|
574
575
|
serialized.httpStatus = this.httpStatus;
|
|
575
576
|
}
|
|
576
577
|
if (this.type !== void 0) {
|
|
577
578
|
serialized.type = this.type;
|
|
578
579
|
}
|
|
580
|
+
if (this.sourceUrl !== void 0) {
|
|
581
|
+
serialized.sourceUrl = this.sourceUrl;
|
|
582
|
+
}
|
|
583
|
+
if (this.docsUrl !== void 0) {
|
|
584
|
+
serialized.docsUrl = this.docsUrl;
|
|
585
|
+
}
|
|
586
|
+
if (this.source !== void 0) {
|
|
587
|
+
serialized.source = this.source;
|
|
588
|
+
}
|
|
579
589
|
if (this.stack) {
|
|
580
590
|
serialized.stack = this.stack;
|
|
581
591
|
}
|
|
582
592
|
if (this.cause) {
|
|
583
|
-
if (this.cause instanceof
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const causeData = {
|
|
587
|
-
name: this.cause.name,
|
|
588
|
-
message: this.cause.message,
|
|
589
|
-
code: "ERROR",
|
|
590
|
-
uiMessage: void 0,
|
|
591
|
-
metadata: {},
|
|
592
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
593
|
+
if (this.cause instanceof Error) {
|
|
594
|
+
const cause = {
|
|
595
|
+
message: this.cause.message
|
|
593
596
|
};
|
|
597
|
+
if (this.cause.name) {
|
|
598
|
+
cause.name = this.cause.name;
|
|
599
|
+
}
|
|
594
600
|
if (this.cause.stack) {
|
|
595
|
-
|
|
601
|
+
cause.stack = this.cause.stack;
|
|
596
602
|
}
|
|
597
|
-
serialized.cause =
|
|
603
|
+
serialized.cause = cause;
|
|
604
|
+
} else if (typeof this.cause === "object" && this.cause !== null) {
|
|
605
|
+
const causeObj = this.cause;
|
|
606
|
+
const cause = {
|
|
607
|
+
message: String(causeObj.message || causeObj)
|
|
608
|
+
};
|
|
609
|
+
if (causeObj.name) {
|
|
610
|
+
cause.name = String(causeObj.name);
|
|
611
|
+
}
|
|
612
|
+
if (causeObj.stack) {
|
|
613
|
+
cause.stack = String(causeObj.stack);
|
|
614
|
+
}
|
|
615
|
+
serialized.cause = cause;
|
|
616
|
+
} else {
|
|
617
|
+
serialized.cause = {
|
|
618
|
+
message: String(this.cause)
|
|
619
|
+
};
|
|
598
620
|
}
|
|
599
621
|
}
|
|
600
622
|
return serialized;
|
|
@@ -628,469 +650,355 @@ ${this.stack}`;
|
|
|
628
650
|
code: serialized.code,
|
|
629
651
|
uiMessage: serialized.uiMessage,
|
|
630
652
|
httpStatus: serialized.httpStatus,
|
|
631
|
-
type: serialized.type
|
|
653
|
+
type: serialized.type,
|
|
654
|
+
sourceUrl: serialized.sourceUrl,
|
|
655
|
+
docsUrl: serialized.docsUrl,
|
|
656
|
+
source: serialized.source
|
|
632
657
|
};
|
|
633
658
|
if (serialized.metadata !== void 0) {
|
|
634
659
|
options.metadata = serialized.metadata;
|
|
635
660
|
}
|
|
636
|
-
if (serialized.actions && serialized.actions.length > 0) {
|
|
637
|
-
options.actions = serialized.actions;
|
|
638
|
-
}
|
|
639
661
|
const error = new _ErrorX(options);
|
|
640
662
|
if (serialized.stack) {
|
|
641
663
|
error.stack = serialized.stack;
|
|
642
664
|
}
|
|
643
|
-
|
|
644
|
-
value: new Date(serialized.timestamp),
|
|
645
|
-
writable: false
|
|
646
|
-
});
|
|
665
|
+
error.timestamp = new Date(serialized.timestamp);
|
|
647
666
|
if (serialized.cause) {
|
|
667
|
+
const causeError = new Error(serialized.cause.message);
|
|
668
|
+
if (serialized.cause.name) {
|
|
669
|
+
causeError.name = serialized.cause.name;
|
|
670
|
+
}
|
|
671
|
+
if (serialized.cause.stack) {
|
|
672
|
+
causeError.stack = serialized.cause.stack;
|
|
673
|
+
}
|
|
648
674
|
Object.defineProperty(error, "cause", {
|
|
649
|
-
value:
|
|
650
|
-
writable:
|
|
675
|
+
value: causeError,
|
|
676
|
+
writable: true
|
|
651
677
|
});
|
|
652
678
|
}
|
|
653
679
|
return error;
|
|
654
680
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
message: "precondition required",
|
|
974
|
-
uiMessage: "Required conditions are missing from the request.",
|
|
975
|
-
type: "http"
|
|
976
|
-
},
|
|
977
|
-
TOO_MANY_REQUESTS: {
|
|
978
|
-
httpStatus: 429,
|
|
979
|
-
code: "TOO_MANY_REQUESTS",
|
|
980
|
-
name: "Too Many Requests Error",
|
|
981
|
-
message: "too many requests",
|
|
982
|
-
uiMessage: "You have made too many requests. Please wait and try again.",
|
|
983
|
-
type: "http"
|
|
984
|
-
},
|
|
985
|
-
REQUEST_HEADER_FIELDS_TOO_LARGE: {
|
|
986
|
-
httpStatus: 431,
|
|
987
|
-
code: "REQUEST_HEADER_FIELDS_TOO_LARGE",
|
|
988
|
-
name: "Request Header Fields Too Large Error",
|
|
989
|
-
message: "request header fields too large",
|
|
990
|
-
uiMessage: "The request headers are too large.",
|
|
991
|
-
type: "http"
|
|
992
|
-
},
|
|
993
|
-
UNAVAILABLE_FOR_LEGAL_REASONS: {
|
|
994
|
-
httpStatus: 451,
|
|
995
|
-
code: "UNAVAILABLE_FOR_LEGAL_REASONS",
|
|
996
|
-
name: "Unavailable For Legal Reasons Error",
|
|
997
|
-
message: "unavailable for legal reasons",
|
|
998
|
-
uiMessage: "This content is unavailable for legal reasons.",
|
|
999
|
-
type: "http"
|
|
1000
|
-
},
|
|
1001
|
-
// 5xx Server Errors
|
|
1002
|
-
INTERNAL_SERVER_ERROR: {
|
|
1003
|
-
httpStatus: 500,
|
|
1004
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
1005
|
-
name: "Internal Server Error",
|
|
1006
|
-
message: "internal server error",
|
|
1007
|
-
uiMessage: "An unexpected error occurred. Please try again later.",
|
|
1008
|
-
type: "http"
|
|
1009
|
-
},
|
|
1010
|
-
NOT_IMPLEMENTED: {
|
|
1011
|
-
httpStatus: 501,
|
|
1012
|
-
code: "NOT_IMPLEMENTED",
|
|
1013
|
-
name: "Not Implemented Error",
|
|
1014
|
-
message: "not implemented",
|
|
1015
|
-
uiMessage: "This feature is not yet available.",
|
|
1016
|
-
type: "http"
|
|
1017
|
-
},
|
|
1018
|
-
BAD_GATEWAY: {
|
|
1019
|
-
httpStatus: 502,
|
|
1020
|
-
code: "BAD_GATEWAY",
|
|
1021
|
-
name: "Bad Gateway Error",
|
|
1022
|
-
message: "bad gateway",
|
|
1023
|
-
uiMessage: "Unable to connect to the server. Please try again later.",
|
|
1024
|
-
type: "http"
|
|
1025
|
-
},
|
|
1026
|
-
SERVICE_UNAVAILABLE: {
|
|
1027
|
-
httpStatus: 503,
|
|
1028
|
-
code: "SERVICE_UNAVAILABLE",
|
|
1029
|
-
name: "Service Unavailable Error",
|
|
1030
|
-
message: "service unavailable",
|
|
1031
|
-
uiMessage: "The service is temporarily unavailable. Please try again later.",
|
|
1032
|
-
type: "http"
|
|
1033
|
-
},
|
|
1034
|
-
GATEWAY_TIMEOUT: {
|
|
1035
|
-
httpStatus: 504,
|
|
1036
|
-
code: "GATEWAY_TIMEOUT",
|
|
1037
|
-
name: "Gateway Timeout Error",
|
|
1038
|
-
message: "gateway timeout",
|
|
1039
|
-
uiMessage: "The server took too long to respond. Please try again.",
|
|
1040
|
-
type: "http"
|
|
1041
|
-
},
|
|
1042
|
-
HTTP_VERSION_NOT_SUPPORTED: {
|
|
1043
|
-
httpStatus: 505,
|
|
1044
|
-
code: "HTTP_VERSION_NOT_SUPPORTED",
|
|
1045
|
-
name: "HTTP Version Not Supported Error",
|
|
1046
|
-
message: "HTTP version not supported",
|
|
1047
|
-
uiMessage: "Your browser version is not supported.",
|
|
1048
|
-
type: "http"
|
|
1049
|
-
},
|
|
1050
|
-
VARIANT_ALSO_NEGOTIATES: {
|
|
1051
|
-
httpStatus: 506,
|
|
1052
|
-
code: "VARIANT_ALSO_NEGOTIATES",
|
|
1053
|
-
name: "Variant Also Negotiates Error",
|
|
1054
|
-
message: "variant also negotiates",
|
|
1055
|
-
uiMessage: "The server has an internal configuration error.",
|
|
1056
|
-
type: "http"
|
|
1057
|
-
},
|
|
1058
|
-
INSUFFICIENT_STORAGE: {
|
|
1059
|
-
httpStatus: 507,
|
|
1060
|
-
code: "INSUFFICIENT_STORAGE",
|
|
1061
|
-
name: "Insufficient Storage Error",
|
|
1062
|
-
message: "insufficient storage",
|
|
1063
|
-
uiMessage: "The server has insufficient storage to complete the request.",
|
|
1064
|
-
type: "http"
|
|
1065
|
-
},
|
|
1066
|
-
LOOP_DETECTED: {
|
|
1067
|
-
httpStatus: 508,
|
|
1068
|
-
code: "LOOP_DETECTED",
|
|
1069
|
-
name: "Loop Detected Error",
|
|
1070
|
-
message: "loop detected",
|
|
1071
|
-
uiMessage: "The server detected an infinite loop.",
|
|
1072
|
-
type: "http"
|
|
1073
|
-
},
|
|
1074
|
-
NOT_EXTENDED: {
|
|
1075
|
-
httpStatus: 510,
|
|
1076
|
-
code: "NOT_EXTENDED",
|
|
1077
|
-
name: "Not Extended Error",
|
|
1078
|
-
message: "not extended",
|
|
1079
|
-
uiMessage: "Additional extensions are required.",
|
|
1080
|
-
type: "http"
|
|
1081
|
-
},
|
|
1082
|
-
NETWORK_AUTHENTICATION_REQUIRED: {
|
|
1083
|
-
httpStatus: 511,
|
|
1084
|
-
code: "NETWORK_AUTHENTICATION_REQUIRED",
|
|
1085
|
-
name: "Network Authentication Required Error",
|
|
1086
|
-
message: "network authentication required",
|
|
1087
|
-
uiMessage: "Network authentication is required to access this resource.",
|
|
1088
|
-
type: "http"
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
// src/presets.ts
|
|
684
|
+
var http = {
|
|
685
|
+
// 4xx Client Errors
|
|
686
|
+
badRequest: {
|
|
687
|
+
httpStatus: 400,
|
|
688
|
+
code: "BAD_REQUEST",
|
|
689
|
+
name: "Bad Request Error",
|
|
690
|
+
message: "Bad request.",
|
|
691
|
+
uiMessage: "The request could not be processed. Please check your input and try again.",
|
|
692
|
+
type: "http"
|
|
693
|
+
},
|
|
694
|
+
unauthorized: {
|
|
695
|
+
httpStatus: 401,
|
|
696
|
+
code: "UNAUTHORIZED",
|
|
697
|
+
name: "Unauthorized Error",
|
|
698
|
+
message: "Unauthorized.",
|
|
699
|
+
uiMessage: "Authentication required. Please log in to continue.",
|
|
700
|
+
type: "http"
|
|
701
|
+
},
|
|
702
|
+
paymentRequired: {
|
|
703
|
+
httpStatus: 402,
|
|
704
|
+
code: "PAYMENT_REQUIRED",
|
|
705
|
+
name: "Payment Required Error",
|
|
706
|
+
message: "Payment required.",
|
|
707
|
+
uiMessage: "Payment is required to access this resource.",
|
|
708
|
+
type: "http"
|
|
709
|
+
},
|
|
710
|
+
forbidden: {
|
|
711
|
+
httpStatus: 403,
|
|
712
|
+
code: "FORBIDDEN",
|
|
713
|
+
name: "Forbidden Error",
|
|
714
|
+
message: "Forbidden.",
|
|
715
|
+
uiMessage: "You do not have permission to access this resource.",
|
|
716
|
+
type: "http"
|
|
717
|
+
},
|
|
718
|
+
notFound: {
|
|
719
|
+
httpStatus: 404,
|
|
720
|
+
code: "NOT_FOUND",
|
|
721
|
+
name: "Not Found Error",
|
|
722
|
+
message: "Not found.",
|
|
723
|
+
uiMessage: "The requested resource could not be found.",
|
|
724
|
+
type: "http"
|
|
725
|
+
},
|
|
726
|
+
methodNotAllowed: {
|
|
727
|
+
httpStatus: 405,
|
|
728
|
+
code: "METHOD_NOT_ALLOWED",
|
|
729
|
+
name: "Method Not Allowed Error",
|
|
730
|
+
message: "Method not allowed.",
|
|
731
|
+
uiMessage: "This action is not allowed for the requested resource.",
|
|
732
|
+
type: "http"
|
|
733
|
+
},
|
|
734
|
+
notAcceptable: {
|
|
735
|
+
httpStatus: 406,
|
|
736
|
+
code: "NOT_ACCEPTABLE",
|
|
737
|
+
name: "Not Acceptable Error",
|
|
738
|
+
message: "Not acceptable.",
|
|
739
|
+
uiMessage: "The requested format is not supported.",
|
|
740
|
+
type: "http"
|
|
741
|
+
},
|
|
742
|
+
proxyAuthenticationRequired: {
|
|
743
|
+
httpStatus: 407,
|
|
744
|
+
code: "PROXY_AUTHENTICATION_REQUIRED",
|
|
745
|
+
name: "Proxy Authentication Required Error",
|
|
746
|
+
message: "Proxy authentication required.",
|
|
747
|
+
uiMessage: "Proxy authentication is required to access this resource.",
|
|
748
|
+
type: "http"
|
|
749
|
+
},
|
|
750
|
+
requestTimeout: {
|
|
751
|
+
httpStatus: 408,
|
|
752
|
+
code: "REQUEST_TIMEOUT",
|
|
753
|
+
name: "Request Timeout Error",
|
|
754
|
+
message: "Request timeout.",
|
|
755
|
+
uiMessage: "The request took too long to complete. Please try again.",
|
|
756
|
+
type: "http"
|
|
757
|
+
},
|
|
758
|
+
conflict: {
|
|
759
|
+
httpStatus: 409,
|
|
760
|
+
code: "CONFLICT",
|
|
761
|
+
name: "Conflict Error",
|
|
762
|
+
message: "Conflict.",
|
|
763
|
+
uiMessage: "The request conflicts with the current state. Please refresh and try again.",
|
|
764
|
+
type: "http"
|
|
765
|
+
},
|
|
766
|
+
gone: {
|
|
767
|
+
httpStatus: 410,
|
|
768
|
+
code: "GONE",
|
|
769
|
+
name: "Gone Error",
|
|
770
|
+
message: "Gone.",
|
|
771
|
+
uiMessage: "This resource is no longer available.",
|
|
772
|
+
type: "http"
|
|
773
|
+
},
|
|
774
|
+
lengthRequired: {
|
|
775
|
+
httpStatus: 411,
|
|
776
|
+
code: "LENGTH_REQUIRED",
|
|
777
|
+
name: "Length Required Error",
|
|
778
|
+
message: "Length required.",
|
|
779
|
+
uiMessage: "The request is missing required length information.",
|
|
780
|
+
type: "http"
|
|
781
|
+
},
|
|
782
|
+
preconditionFailed: {
|
|
783
|
+
httpStatus: 412,
|
|
784
|
+
code: "PRECONDITION_FAILED",
|
|
785
|
+
name: "Precondition Failed Error",
|
|
786
|
+
message: "Precondition failed.",
|
|
787
|
+
uiMessage: "A required condition was not met. Please try again.",
|
|
788
|
+
type: "http"
|
|
789
|
+
},
|
|
790
|
+
payloadTooLarge: {
|
|
791
|
+
httpStatus: 413,
|
|
792
|
+
code: "PAYLOAD_TOO_LARGE",
|
|
793
|
+
name: "Payload Too Large Error",
|
|
794
|
+
message: "Payload too large.",
|
|
795
|
+
uiMessage: "The request is too large. Please reduce the size and try again.",
|
|
796
|
+
type: "http"
|
|
797
|
+
},
|
|
798
|
+
uriTooLong: {
|
|
799
|
+
httpStatus: 414,
|
|
800
|
+
code: "URI_TOO_LONG",
|
|
801
|
+
name: "URI Too Long Error",
|
|
802
|
+
message: "URI too long.",
|
|
803
|
+
uiMessage: "The request URL is too long.",
|
|
804
|
+
type: "http"
|
|
805
|
+
},
|
|
806
|
+
unsupportedMediaType: {
|
|
807
|
+
httpStatus: 415,
|
|
808
|
+
code: "UNSUPPORTED_MEDIA_TYPE",
|
|
809
|
+
name: "Unsupported Media Type Error",
|
|
810
|
+
message: "Unsupported media type.",
|
|
811
|
+
uiMessage: "The file type is not supported.",
|
|
812
|
+
type: "http"
|
|
813
|
+
},
|
|
814
|
+
rangeNotSatisfiable: {
|
|
815
|
+
httpStatus: 416,
|
|
816
|
+
code: "RANGE_NOT_SATISFIABLE",
|
|
817
|
+
name: "Range Not Satisfiable Error",
|
|
818
|
+
message: "Range not satisfiable.",
|
|
819
|
+
uiMessage: "The requested range cannot be satisfied.",
|
|
820
|
+
type: "http"
|
|
821
|
+
},
|
|
822
|
+
expectationFailed: {
|
|
823
|
+
httpStatus: 417,
|
|
824
|
+
code: "EXPECTATION_FAILED",
|
|
825
|
+
name: "Expectation Failed Error",
|
|
826
|
+
message: "Expectation failed.",
|
|
827
|
+
uiMessage: "The server cannot meet the requirements of the request.",
|
|
828
|
+
type: "http"
|
|
829
|
+
},
|
|
830
|
+
imATeapot: {
|
|
831
|
+
httpStatus: 418,
|
|
832
|
+
code: "IM_A_TEAPOT",
|
|
833
|
+
name: "Im A Teapot Error",
|
|
834
|
+
message: "I'm a teapot.",
|
|
835
|
+
uiMessage: "I'm a teapot and cannot brew coffee.",
|
|
836
|
+
type: "http"
|
|
837
|
+
},
|
|
838
|
+
unprocessableEntity: {
|
|
839
|
+
httpStatus: 422,
|
|
840
|
+
code: "UNPROCESSABLE_ENTITY",
|
|
841
|
+
name: "Unprocessable Entity Error",
|
|
842
|
+
message: "Unprocessable entity.",
|
|
843
|
+
uiMessage: "The request contains invalid data. Please check your input.",
|
|
844
|
+
type: "http"
|
|
845
|
+
},
|
|
846
|
+
locked: {
|
|
847
|
+
httpStatus: 423,
|
|
848
|
+
code: "LOCKED",
|
|
849
|
+
name: "Locked Error",
|
|
850
|
+
message: "Locked.",
|
|
851
|
+
uiMessage: "This resource is locked and cannot be modified.",
|
|
852
|
+
type: "http"
|
|
853
|
+
},
|
|
854
|
+
failedDependency: {
|
|
855
|
+
httpStatus: 424,
|
|
856
|
+
code: "FAILED_DEPENDENCY",
|
|
857
|
+
name: "Failed Dependency Error",
|
|
858
|
+
message: "Failed dependency.",
|
|
859
|
+
uiMessage: "The request failed due to a dependency error.",
|
|
860
|
+
type: "http"
|
|
861
|
+
},
|
|
862
|
+
tooEarly: {
|
|
863
|
+
httpStatus: 425,
|
|
864
|
+
code: "TOO_EARLY",
|
|
865
|
+
name: "Too Early Error",
|
|
866
|
+
message: "Too early.",
|
|
867
|
+
uiMessage: "The request was sent too early. Please try again later.",
|
|
868
|
+
type: "http"
|
|
869
|
+
},
|
|
870
|
+
upgradeRequired: {
|
|
871
|
+
httpStatus: 426,
|
|
872
|
+
code: "UPGRADE_REQUIRED",
|
|
873
|
+
name: "Upgrade Required Error",
|
|
874
|
+
message: "Upgrade required.",
|
|
875
|
+
uiMessage: "Please upgrade to continue using this service.",
|
|
876
|
+
type: "http"
|
|
877
|
+
},
|
|
878
|
+
preconditionRequired: {
|
|
879
|
+
httpStatus: 428,
|
|
880
|
+
code: "PRECONDITION_REQUIRED",
|
|
881
|
+
name: "Precondition Required Error",
|
|
882
|
+
message: "Precondition required.",
|
|
883
|
+
uiMessage: "Required conditions are missing from the request.",
|
|
884
|
+
type: "http"
|
|
885
|
+
},
|
|
886
|
+
tooManyRequests: {
|
|
887
|
+
httpStatus: 429,
|
|
888
|
+
code: "TOO_MANY_REQUESTS",
|
|
889
|
+
name: "Too Many Requests Error",
|
|
890
|
+
message: "Too many requests.",
|
|
891
|
+
uiMessage: "You have made too many requests. Please wait and try again.",
|
|
892
|
+
type: "http"
|
|
893
|
+
},
|
|
894
|
+
requestHeaderFieldsTooLarge: {
|
|
895
|
+
httpStatus: 431,
|
|
896
|
+
code: "REQUEST_HEADER_FIELDS_TOO_LARGE",
|
|
897
|
+
name: "Request Header Fields Too Large Error",
|
|
898
|
+
message: "Request header fields too large.",
|
|
899
|
+
uiMessage: "The request headers are too large.",
|
|
900
|
+
type: "http"
|
|
901
|
+
},
|
|
902
|
+
unavailableForLegalReasons: {
|
|
903
|
+
httpStatus: 451,
|
|
904
|
+
code: "UNAVAILABLE_FOR_LEGAL_REASONS",
|
|
905
|
+
name: "Unavailable For Legal Reasons Error",
|
|
906
|
+
message: "Unavailable for legal reasons.",
|
|
907
|
+
uiMessage: "This content is unavailable for legal reasons.",
|
|
908
|
+
type: "http"
|
|
909
|
+
},
|
|
910
|
+
// 5xx Server Errors
|
|
911
|
+
internalServerError: {
|
|
912
|
+
httpStatus: 500,
|
|
913
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
914
|
+
name: "Internal Server Error",
|
|
915
|
+
message: "Internal server error.",
|
|
916
|
+
uiMessage: "An unexpected error occurred. Please try again later.",
|
|
917
|
+
type: "http"
|
|
918
|
+
},
|
|
919
|
+
notImplemented: {
|
|
920
|
+
httpStatus: 501,
|
|
921
|
+
code: "NOT_IMPLEMENTED",
|
|
922
|
+
name: "Not Implemented Error",
|
|
923
|
+
message: "Not implemented.",
|
|
924
|
+
uiMessage: "This feature is not yet available.",
|
|
925
|
+
type: "http"
|
|
926
|
+
},
|
|
927
|
+
badGateway: {
|
|
928
|
+
httpStatus: 502,
|
|
929
|
+
code: "BAD_GATEWAY",
|
|
930
|
+
name: "Bad Gateway Error",
|
|
931
|
+
message: "Bad gateway.",
|
|
932
|
+
uiMessage: "Unable to connect to the server. Please try again later.",
|
|
933
|
+
type: "http"
|
|
934
|
+
},
|
|
935
|
+
serviceUnavailable: {
|
|
936
|
+
httpStatus: 503,
|
|
937
|
+
code: "SERVICE_UNAVAILABLE",
|
|
938
|
+
name: "Service Unavailable Error",
|
|
939
|
+
message: "Service unavailable.",
|
|
940
|
+
uiMessage: "The service is temporarily unavailable. Please try again later.",
|
|
941
|
+
type: "http"
|
|
942
|
+
},
|
|
943
|
+
gatewayTimeout: {
|
|
944
|
+
httpStatus: 504,
|
|
945
|
+
code: "GATEWAY_TIMEOUT",
|
|
946
|
+
name: "Gateway Timeout Error",
|
|
947
|
+
message: "Gateway timeout.",
|
|
948
|
+
uiMessage: "The server took too long to respond. Please try again.",
|
|
949
|
+
type: "http"
|
|
950
|
+
},
|
|
951
|
+
httpVersionNotSupported: {
|
|
952
|
+
httpStatus: 505,
|
|
953
|
+
code: "HTTP_VERSION_NOT_SUPPORTED",
|
|
954
|
+
name: "HTTP Version Not Supported Error",
|
|
955
|
+
message: "HTTP version not supported.",
|
|
956
|
+
uiMessage: "Your browser version is not supported.",
|
|
957
|
+
type: "http"
|
|
958
|
+
},
|
|
959
|
+
variantAlsoNegotiates: {
|
|
960
|
+
httpStatus: 506,
|
|
961
|
+
code: "VARIANT_ALSO_NEGOTIATES",
|
|
962
|
+
name: "Variant Also Negotiates Error",
|
|
963
|
+
message: "Variant also negotiates.",
|
|
964
|
+
uiMessage: "The server has an internal configuration error.",
|
|
965
|
+
type: "http"
|
|
966
|
+
},
|
|
967
|
+
insufficientStorage: {
|
|
968
|
+
httpStatus: 507,
|
|
969
|
+
code: "INSUFFICIENT_STORAGE",
|
|
970
|
+
name: "Insufficient Storage Error",
|
|
971
|
+
message: "Insufficient storage.",
|
|
972
|
+
uiMessage: "The server has insufficient storage to complete the request.",
|
|
973
|
+
type: "http"
|
|
974
|
+
},
|
|
975
|
+
loopDetected: {
|
|
976
|
+
httpStatus: 508,
|
|
977
|
+
code: "LOOP_DETECTED",
|
|
978
|
+
name: "Loop Detected Error",
|
|
979
|
+
message: "Loop detected.",
|
|
980
|
+
uiMessage: "The server detected an infinite loop.",
|
|
981
|
+
type: "http"
|
|
982
|
+
},
|
|
983
|
+
notExtended: {
|
|
984
|
+
httpStatus: 510,
|
|
985
|
+
code: "NOT_EXTENDED",
|
|
986
|
+
name: "Not Extended Error",
|
|
987
|
+
message: "Not extended.",
|
|
988
|
+
uiMessage: "Additional extensions are required.",
|
|
989
|
+
type: "http"
|
|
990
|
+
},
|
|
991
|
+
networkAuthenticationRequired: {
|
|
992
|
+
httpStatus: 511,
|
|
993
|
+
code: "NETWORK_AUTHENTICATION_REQUIRED",
|
|
994
|
+
name: "Network Authentication Required Error",
|
|
995
|
+
message: "Network authentication required.",
|
|
996
|
+
uiMessage: "Network authentication is required to access this resource.",
|
|
997
|
+
type: "http"
|
|
998
|
+
}
|
|
1091
999
|
};
|
|
1092
1000
|
|
|
1093
1001
|
exports.ErrorX = ErrorX;
|
|
1094
|
-
exports.
|
|
1002
|
+
exports.http = http;
|
|
1095
1003
|
//# sourceMappingURL=index.cjs.map
|
|
1096
1004
|
//# sourceMappingURL=index.cjs.map
|