@bombillazo/error-x 0.3.0 → 0.4.1
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 +511 -608
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +593 -680
- package/dist/index.d.ts +593 -680
- package/dist/index.js +511 -608
- 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,73 +36,85 @@ 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;
|
|
49
|
+
/** Original error that caused this error (preserves error chain) */
|
|
50
|
+
cause;
|
|
51
51
|
/**
|
|
52
52
|
* Creates a new ErrorX instance with enhanced error handling capabilities.
|
|
53
53
|
*
|
|
54
|
-
* @param messageOrOptions - Error message string
|
|
55
|
-
* @param additionalOptions - Additional options when first parameter is a string (optional)
|
|
54
|
+
* @param messageOrOptions - Error message string or ErrorXOptions object (optional)
|
|
56
55
|
*
|
|
57
56
|
* @example
|
|
58
57
|
* ```typescript
|
|
58
|
+
* // Create with default message
|
|
59
|
+
* const error1 = new ErrorX()
|
|
60
|
+
*
|
|
59
61
|
* // Create with string message only
|
|
60
|
-
* const
|
|
62
|
+
* const error2 = new ErrorX('Database query failed')
|
|
61
63
|
*
|
|
62
|
-
* // Create with
|
|
63
|
-
* const
|
|
64
|
+
* // Create with options object
|
|
65
|
+
* const error3 = new ErrorX({
|
|
66
|
+
* message: 'Database query failed',
|
|
64
67
|
* name: 'DatabaseError',
|
|
65
68
|
* code: 'DB_QUERY_FAILED',
|
|
66
69
|
* uiMessage: 'Unable to load data. Please try again.',
|
|
67
70
|
* metadata: { query: 'SELECT * FROM users', timeout: 5000 }
|
|
68
71
|
* })
|
|
69
72
|
*
|
|
70
|
-
* //
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* actions: [
|
|
76
|
-
* { action: 'notify', payload: { targets: [HandlingTargets.TOAST] } }
|
|
77
|
-
* ]
|
|
73
|
+
* // With type-safe metadata
|
|
74
|
+
* type MyMeta = { userId: number };
|
|
75
|
+
* const error4 = new ErrorX<MyMeta>({
|
|
76
|
+
* message: 'User action failed',
|
|
77
|
+
* metadata: { userId: 123 }
|
|
78
78
|
* })
|
|
79
79
|
*
|
|
80
|
-
* //
|
|
80
|
+
* // For converting unknown errors, use ErrorX.from()
|
|
81
81
|
* const apiError = { message: 'User not found', code: 404 }
|
|
82
|
-
* const
|
|
83
|
-
*
|
|
84
|
-
* // Create with no options (uses defaults)
|
|
85
|
-
* const error5 = new ErrorX()
|
|
82
|
+
* const error5 = ErrorX.from(apiError)
|
|
86
83
|
* ```
|
|
87
84
|
*/
|
|
88
|
-
constructor(messageOrOptions
|
|
85
|
+
constructor(messageOrOptions) {
|
|
89
86
|
let options = {};
|
|
90
87
|
if (typeof messageOrOptions === "string") {
|
|
91
|
-
options = {
|
|
92
|
-
message: messageOrOptions,
|
|
93
|
-
...additionalOptions
|
|
94
|
-
};
|
|
95
|
-
} else if (_ErrorX.isErrorXOptions(messageOrOptions)) {
|
|
96
|
-
options = messageOrOptions;
|
|
88
|
+
options = { message: messageOrOptions };
|
|
97
89
|
} else if (messageOrOptions != null) {
|
|
98
|
-
options =
|
|
90
|
+
options = messageOrOptions;
|
|
99
91
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
92
|
+
const envConfig = _ErrorX.getConfig();
|
|
93
|
+
const message = options.message?.trim() ? options.message : "An error occurred";
|
|
94
|
+
const convertedCause = _ErrorX.toErrorXCause(options.cause);
|
|
95
|
+
super(message);
|
|
96
|
+
this.cause = convertedCause;
|
|
102
97
|
this.name = options.name ?? _ErrorX.getDefaultName();
|
|
103
98
|
this.code = options.code != null ? String(options.code) : _ErrorX.generateDefaultCode(options.name);
|
|
104
99
|
this.uiMessage = options.uiMessage;
|
|
105
100
|
this.metadata = options.metadata;
|
|
106
|
-
this.actions = options.actions;
|
|
107
101
|
this.httpStatus = _ErrorX.validateHttpStatus(options.httpStatus);
|
|
108
102
|
this.type = _ErrorX.validateType(options.type);
|
|
109
103
|
this.timestamp = /* @__PURE__ */ new Date();
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
this.sourceUrl = options.sourceUrl;
|
|
105
|
+
this.source = options.source ?? envConfig?.source;
|
|
106
|
+
let generatedDocsUrl;
|
|
107
|
+
if (envConfig?.docsBaseURL && envConfig?.docsMap && this.code) {
|
|
108
|
+
const docPath = envConfig.docsMap[this.code];
|
|
109
|
+
if (docPath) {
|
|
110
|
+
const base = envConfig.docsBaseURL.replace(/\/+$/, "");
|
|
111
|
+
const path = docPath.replace(/^\/+/, "");
|
|
112
|
+
generatedDocsUrl = `${base}/${path}`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this.docsUrl = options.docsUrl ?? generatedDocsUrl;
|
|
116
|
+
if (convertedCause?.stack) {
|
|
117
|
+
this.stack = _ErrorX.preserveOriginalStackFromCause(convertedCause, this);
|
|
112
118
|
} else {
|
|
113
119
|
if (typeof Error.captureStackTrace === "function") {
|
|
114
120
|
Error.captureStackTrace(this, this.constructor);
|
|
@@ -123,6 +129,72 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
123
129
|
static getDefaultName() {
|
|
124
130
|
return "Error";
|
|
125
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Converts any value to ErrorXCause format.
|
|
134
|
+
* @param value - Value to convert to ErrorXCause
|
|
135
|
+
* @returns ErrorXCause object or undefined if value is null/undefined
|
|
136
|
+
*/
|
|
137
|
+
static toErrorXCause(value) {
|
|
138
|
+
if (value === void 0 || value === null) {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
if (value instanceof Error) {
|
|
142
|
+
const cause = {
|
|
143
|
+
message: value.message
|
|
144
|
+
};
|
|
145
|
+
if (value.name) {
|
|
146
|
+
cause.name = value.name;
|
|
147
|
+
}
|
|
148
|
+
if (value.stack) {
|
|
149
|
+
cause.stack = value.stack;
|
|
150
|
+
}
|
|
151
|
+
return cause;
|
|
152
|
+
}
|
|
153
|
+
if (typeof value === "object") {
|
|
154
|
+
const obj = value;
|
|
155
|
+
const cause = {
|
|
156
|
+
message: String(obj.message || obj)
|
|
157
|
+
};
|
|
158
|
+
if (obj.name) {
|
|
159
|
+
cause.name = String(obj.name);
|
|
160
|
+
}
|
|
161
|
+
if (obj.stack) {
|
|
162
|
+
cause.stack = String(obj.stack);
|
|
163
|
+
}
|
|
164
|
+
return cause;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
message: String(value)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Configure global ErrorX settings.
|
|
172
|
+
* This method allows you to set defaults for all ErrorX instances.
|
|
173
|
+
*
|
|
174
|
+
* @param config - Configuration object
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* ErrorX.configure({
|
|
179
|
+
* source: 'my-api-service',
|
|
180
|
+
* docsBaseURL: 'https://docs.example.com/errors',
|
|
181
|
+
* docsMap: {
|
|
182
|
+
* 'AUTH_FAILED': 'authentication-errors',
|
|
183
|
+
* 'DB_ERROR': 'database-errors'
|
|
184
|
+
* }
|
|
185
|
+
* })
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
static configure(config) {
|
|
189
|
+
_ErrorX._config = { ..._ErrorX._config || {}, ...config };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get the current global configuration.
|
|
193
|
+
* Returns null if no configuration has been set.
|
|
194
|
+
*/
|
|
195
|
+
static getConfig() {
|
|
196
|
+
return _ErrorX._config;
|
|
197
|
+
}
|
|
126
198
|
/**
|
|
127
199
|
* Validates HTTP status code to ensure it's within valid range (100-599)
|
|
128
200
|
*
|
|
@@ -196,16 +268,16 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
196
268
|
}
|
|
197
269
|
/**
|
|
198
270
|
* Preserves the original error's stack trace while updating the error message.
|
|
199
|
-
* Combines the new error's message with the original error's stack trace.
|
|
271
|
+
* Combines the new error's message with the original error's stack trace from ErrorXCause.
|
|
200
272
|
*
|
|
201
|
-
* @param
|
|
273
|
+
* @param cause - The ErrorXCause containing the original stack to preserve
|
|
202
274
|
* @param newError - The new error whose message to use
|
|
203
275
|
* @returns Combined stack trace with new error message and original stack
|
|
204
276
|
*/
|
|
205
|
-
static
|
|
206
|
-
if (!
|
|
277
|
+
static preserveOriginalStackFromCause(cause, newError) {
|
|
278
|
+
if (!cause.stack) return newError.stack || "";
|
|
207
279
|
const newErrorFirstLine = `${newError.name}: ${newError.message}`;
|
|
208
|
-
const originalStackLines =
|
|
280
|
+
const originalStackLines = cause.stack.split("\n");
|
|
209
281
|
const originalStackTrace = originalStackLines.slice(1);
|
|
210
282
|
return [newErrorFirstLine, ...originalStackTrace].join("\n");
|
|
211
283
|
}
|
|
@@ -218,10 +290,24 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
218
290
|
*/
|
|
219
291
|
static cleanStack(stack) {
|
|
220
292
|
if (!stack) return "";
|
|
293
|
+
const config = _ErrorX.getConfig();
|
|
294
|
+
const cleanStackConfig = config?.cleanStack ?? true;
|
|
295
|
+
if (cleanStackConfig === false) {
|
|
296
|
+
return stack;
|
|
297
|
+
}
|
|
221
298
|
const stackLines = stack.split("\n");
|
|
222
299
|
const cleanedLines = [];
|
|
300
|
+
const defaultPatterns = [
|
|
301
|
+
"new ErrorX",
|
|
302
|
+
"ErrorX.constructor",
|
|
303
|
+
"ErrorX.from",
|
|
304
|
+
"error-x/dist/",
|
|
305
|
+
"error-x/src/error.ts"
|
|
306
|
+
];
|
|
307
|
+
const patterns = Array.isArray(cleanStackConfig) ? cleanStackConfig : defaultPatterns;
|
|
223
308
|
for (const line of stackLines) {
|
|
224
|
-
|
|
309
|
+
const shouldSkip = patterns.some((pattern) => line.includes(pattern));
|
|
310
|
+
if (shouldSkip) {
|
|
225
311
|
continue;
|
|
226
312
|
}
|
|
227
313
|
cleanedLines.push(line);
|
|
@@ -251,35 +337,6 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
251
337
|
}
|
|
252
338
|
return stack;
|
|
253
339
|
}
|
|
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
340
|
/**
|
|
284
341
|
* Creates a new ErrorX instance with additional metadata merged with existing metadata.
|
|
285
342
|
* The original error properties are preserved while extending the metadata.
|
|
@@ -310,15 +367,16 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
310
367
|
cause: this.cause,
|
|
311
368
|
metadata: { ...this.metadata ?? {}, ...additionalMetadata },
|
|
312
369
|
httpStatus: this.httpStatus,
|
|
313
|
-
type: this.type
|
|
370
|
+
type: this.type,
|
|
371
|
+
sourceUrl: this.sourceUrl,
|
|
372
|
+
docsUrl: this.docsUrl,
|
|
373
|
+
source: this.source
|
|
314
374
|
};
|
|
315
|
-
if (this.actions) {
|
|
316
|
-
options.actions = this.actions;
|
|
317
|
-
}
|
|
318
375
|
const newError = new _ErrorX(options);
|
|
319
376
|
if (this.stack) {
|
|
320
377
|
newError.stack = this.stack;
|
|
321
378
|
}
|
|
379
|
+
newError.timestamp = this.timestamp;
|
|
322
380
|
return newError;
|
|
323
381
|
}
|
|
324
382
|
/**
|
|
@@ -358,9 +416,11 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
358
416
|
let uiMessage = "";
|
|
359
417
|
let cause;
|
|
360
418
|
let metadata = {};
|
|
361
|
-
let actions;
|
|
362
419
|
let httpStatus;
|
|
363
420
|
let type;
|
|
421
|
+
let url;
|
|
422
|
+
let href;
|
|
423
|
+
let source;
|
|
364
424
|
if (error) {
|
|
365
425
|
if (typeof error === "string") {
|
|
366
426
|
message = error;
|
|
@@ -383,9 +443,6 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
383
443
|
if ("code" in error && error.code) code = String(error.code);
|
|
384
444
|
if ("uiMessage" in error && error.uiMessage) uiMessage = String(error.uiMessage);
|
|
385
445
|
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
446
|
let _httpStatus;
|
|
390
447
|
if ("httpStatus" in error) {
|
|
391
448
|
_httpStatus = error.httpStatus;
|
|
@@ -401,6 +458,25 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
401
458
|
if ("type" in error && error.type) {
|
|
402
459
|
type = _ErrorX.validateType(String(error.type));
|
|
403
460
|
}
|
|
461
|
+
if ("sourceUrl" in error && error.sourceUrl) {
|
|
462
|
+
url = String(error.sourceUrl);
|
|
463
|
+
} else if ("url" in error && error.url) {
|
|
464
|
+
url = String(error.url);
|
|
465
|
+
}
|
|
466
|
+
if ("docsUrl" in error && error.docsUrl) {
|
|
467
|
+
href = String(error.docsUrl);
|
|
468
|
+
} else if ("href" in error && error.href) {
|
|
469
|
+
href = String(error.href);
|
|
470
|
+
} else if ("documentationUrl" in error && error.documentationUrl) {
|
|
471
|
+
href = String(error.documentationUrl);
|
|
472
|
+
}
|
|
473
|
+
if ("source" in error && error.source) {
|
|
474
|
+
source = String(error.source);
|
|
475
|
+
} else if ("service" in error && error.service) {
|
|
476
|
+
source = String(error.service);
|
|
477
|
+
} else if ("component" in error && error.component) {
|
|
478
|
+
source = String(error.component);
|
|
479
|
+
}
|
|
404
480
|
metadata = { originalError: error };
|
|
405
481
|
}
|
|
406
482
|
}
|
|
@@ -412,58 +488,18 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
412
488
|
if (uiMessage) options.uiMessage = uiMessage;
|
|
413
489
|
if (cause) options.cause = cause;
|
|
414
490
|
if (Object.keys(metadata).length > 0) options.metadata = metadata;
|
|
415
|
-
if (actions && actions.length > 0) options.actions = actions;
|
|
416
491
|
if (httpStatus) options.httpStatus = httpStatus;
|
|
417
492
|
if (type) options.type = type;
|
|
493
|
+
if (url) options.sourceUrl = url;
|
|
494
|
+
if (href) options.docsUrl = href;
|
|
495
|
+
if (source) options.source = source;
|
|
418
496
|
return options;
|
|
419
497
|
}
|
|
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) {
|
|
498
|
+
static from(error) {
|
|
445
499
|
if (error instanceof _ErrorX) return error;
|
|
446
500
|
const options = _ErrorX.convertUnknownToOptions(error);
|
|
447
501
|
return new _ErrorX(options);
|
|
448
502
|
}
|
|
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
503
|
/**
|
|
468
504
|
* Creates a new ErrorX instance with cleaned stack trace using the specified delimiter.
|
|
469
505
|
* Returns the same instance if no delimiter is provided or no stack is available.
|
|
@@ -487,14 +523,14 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
487
523
|
uiMessage: this.uiMessage,
|
|
488
524
|
cause: this.cause,
|
|
489
525
|
httpStatus: this.httpStatus,
|
|
490
|
-
type: this.type
|
|
526
|
+
type: this.type,
|
|
527
|
+
sourceUrl: this.sourceUrl,
|
|
528
|
+
docsUrl: this.docsUrl,
|
|
529
|
+
source: this.source
|
|
491
530
|
};
|
|
492
531
|
if (this.metadata !== void 0) {
|
|
493
532
|
options.metadata = this.metadata;
|
|
494
533
|
}
|
|
495
|
-
if (this.actions) {
|
|
496
|
-
options.actions = this.actions;
|
|
497
|
-
}
|
|
498
534
|
const newError = new _ErrorX(options);
|
|
499
535
|
newError.stack = _ErrorX.processErrorStack(this, delimiter);
|
|
500
536
|
return newError;
|
|
@@ -557,7 +593,10 @@ ${this.stack}`;
|
|
|
557
593
|
* ```
|
|
558
594
|
*/
|
|
559
595
|
toJSON() {
|
|
560
|
-
|
|
596
|
+
let safeMetadata;
|
|
597
|
+
if (this.metadata) {
|
|
598
|
+
safeMetadata = JSON.parse(safeStringify__default.default(this.metadata));
|
|
599
|
+
}
|
|
561
600
|
const serialized = {
|
|
562
601
|
name: this.name,
|
|
563
602
|
message: this.message,
|
|
@@ -566,36 +605,26 @@ ${this.stack}`;
|
|
|
566
605
|
metadata: safeMetadata,
|
|
567
606
|
timestamp: this.timestamp.toISOString()
|
|
568
607
|
};
|
|
569
|
-
if (this.actions && this.actions.length > 0) {
|
|
570
|
-
const stringified = safeStringify__default.default(this.actions);
|
|
571
|
-
serialized.actions = JSON.parse(stringified);
|
|
572
|
-
}
|
|
573
608
|
if (this.httpStatus !== void 0) {
|
|
574
609
|
serialized.httpStatus = this.httpStatus;
|
|
575
610
|
}
|
|
576
611
|
if (this.type !== void 0) {
|
|
577
612
|
serialized.type = this.type;
|
|
578
613
|
}
|
|
614
|
+
if (this.sourceUrl !== void 0) {
|
|
615
|
+
serialized.sourceUrl = this.sourceUrl;
|
|
616
|
+
}
|
|
617
|
+
if (this.docsUrl !== void 0) {
|
|
618
|
+
serialized.docsUrl = this.docsUrl;
|
|
619
|
+
}
|
|
620
|
+
if (this.source !== void 0) {
|
|
621
|
+
serialized.source = this.source;
|
|
622
|
+
}
|
|
579
623
|
if (this.stack) {
|
|
580
624
|
serialized.stack = this.stack;
|
|
581
625
|
}
|
|
582
626
|
if (this.cause) {
|
|
583
|
-
|
|
584
|
-
serialized.cause = this.cause.toJSON();
|
|
585
|
-
} else if (this.cause instanceof Error) {
|
|
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
|
-
};
|
|
594
|
-
if (this.cause.stack) {
|
|
595
|
-
causeData.stack = this.cause.stack;
|
|
596
|
-
}
|
|
597
|
-
serialized.cause = causeData;
|
|
598
|
-
}
|
|
627
|
+
serialized.cause = this.cause;
|
|
599
628
|
}
|
|
600
629
|
return serialized;
|
|
601
630
|
}
|
|
@@ -628,469 +657,343 @@ ${this.stack}`;
|
|
|
628
657
|
code: serialized.code,
|
|
629
658
|
uiMessage: serialized.uiMessage,
|
|
630
659
|
httpStatus: serialized.httpStatus,
|
|
631
|
-
type: serialized.type
|
|
660
|
+
type: serialized.type,
|
|
661
|
+
sourceUrl: serialized.sourceUrl,
|
|
662
|
+
docsUrl: serialized.docsUrl,
|
|
663
|
+
source: serialized.source,
|
|
664
|
+
cause: serialized.cause
|
|
632
665
|
};
|
|
633
666
|
if (serialized.metadata !== void 0) {
|
|
634
667
|
options.metadata = serialized.metadata;
|
|
635
668
|
}
|
|
636
|
-
if (serialized.actions && serialized.actions.length > 0) {
|
|
637
|
-
options.actions = serialized.actions;
|
|
638
|
-
}
|
|
639
669
|
const error = new _ErrorX(options);
|
|
640
670
|
if (serialized.stack) {
|
|
641
671
|
error.stack = serialized.stack;
|
|
642
672
|
}
|
|
643
|
-
|
|
644
|
-
value: new Date(serialized.timestamp),
|
|
645
|
-
writable: false
|
|
646
|
-
});
|
|
647
|
-
if (serialized.cause) {
|
|
648
|
-
Object.defineProperty(error, "cause", {
|
|
649
|
-
value: _ErrorX.fromJSON(serialized.cause),
|
|
650
|
-
writable: false
|
|
651
|
-
});
|
|
652
|
-
}
|
|
673
|
+
error.timestamp = new Date(serialized.timestamp);
|
|
653
674
|
return error;
|
|
654
675
|
}
|
|
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
|
-
};
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// src/presets.ts
|
|
679
|
+
var http = {
|
|
680
|
+
// 4xx Client Errors
|
|
681
|
+
badRequest: {
|
|
682
|
+
httpStatus: 400,
|
|
683
|
+
code: "BAD_REQUEST",
|
|
684
|
+
name: "Bad Request Error",
|
|
685
|
+
message: "Bad request.",
|
|
686
|
+
uiMessage: "The request could not be processed. Please check your input and try again.",
|
|
687
|
+
type: "http"
|
|
688
|
+
},
|
|
689
|
+
unauthorized: {
|
|
690
|
+
httpStatus: 401,
|
|
691
|
+
code: "UNAUTHORIZED",
|
|
692
|
+
name: "Unauthorized Error",
|
|
693
|
+
message: "Unauthorized.",
|
|
694
|
+
uiMessage: "Authentication required. Please log in to continue.",
|
|
695
|
+
type: "http"
|
|
696
|
+
},
|
|
697
|
+
paymentRequired: {
|
|
698
|
+
httpStatus: 402,
|
|
699
|
+
code: "PAYMENT_REQUIRED",
|
|
700
|
+
name: "Payment Required Error",
|
|
701
|
+
message: "Payment required.",
|
|
702
|
+
uiMessage: "Payment is required to access this resource.",
|
|
703
|
+
type: "http"
|
|
704
|
+
},
|
|
705
|
+
forbidden: {
|
|
706
|
+
httpStatus: 403,
|
|
707
|
+
code: "FORBIDDEN",
|
|
708
|
+
name: "Forbidden Error",
|
|
709
|
+
message: "Forbidden.",
|
|
710
|
+
uiMessage: "You do not have permission to access this resource.",
|
|
711
|
+
type: "http"
|
|
712
|
+
},
|
|
713
|
+
notFound: {
|
|
714
|
+
httpStatus: 404,
|
|
715
|
+
code: "NOT_FOUND",
|
|
716
|
+
name: "Not Found Error",
|
|
717
|
+
message: "Not found.",
|
|
718
|
+
uiMessage: "The requested resource could not be found.",
|
|
719
|
+
type: "http"
|
|
720
|
+
},
|
|
721
|
+
methodNotAllowed: {
|
|
722
|
+
httpStatus: 405,
|
|
723
|
+
code: "METHOD_NOT_ALLOWED",
|
|
724
|
+
name: "Method Not Allowed Error",
|
|
725
|
+
message: "Method not allowed.",
|
|
726
|
+
uiMessage: "This action is not allowed for the requested resource.",
|
|
727
|
+
type: "http"
|
|
728
|
+
},
|
|
729
|
+
notAcceptable: {
|
|
730
|
+
httpStatus: 406,
|
|
731
|
+
code: "NOT_ACCEPTABLE",
|
|
732
|
+
name: "Not Acceptable Error",
|
|
733
|
+
message: "Not acceptable.",
|
|
734
|
+
uiMessage: "The requested format is not supported.",
|
|
735
|
+
type: "http"
|
|
736
|
+
},
|
|
737
|
+
proxyAuthenticationRequired: {
|
|
738
|
+
httpStatus: 407,
|
|
739
|
+
code: "PROXY_AUTHENTICATION_REQUIRED",
|
|
740
|
+
name: "Proxy Authentication Required Error",
|
|
741
|
+
message: "Proxy authentication required.",
|
|
742
|
+
uiMessage: "Proxy authentication is required to access this resource.",
|
|
743
|
+
type: "http"
|
|
744
|
+
},
|
|
745
|
+
requestTimeout: {
|
|
746
|
+
httpStatus: 408,
|
|
747
|
+
code: "REQUEST_TIMEOUT",
|
|
748
|
+
name: "Request Timeout Error",
|
|
749
|
+
message: "Request timeout.",
|
|
750
|
+
uiMessage: "The request took too long to complete. Please try again.",
|
|
751
|
+
type: "http"
|
|
752
|
+
},
|
|
753
|
+
conflict: {
|
|
754
|
+
httpStatus: 409,
|
|
755
|
+
code: "CONFLICT",
|
|
756
|
+
name: "Conflict Error",
|
|
757
|
+
message: "Conflict.",
|
|
758
|
+
uiMessage: "The request conflicts with the current state. Please refresh and try again.",
|
|
759
|
+
type: "http"
|
|
760
|
+
},
|
|
761
|
+
gone: {
|
|
762
|
+
httpStatus: 410,
|
|
763
|
+
code: "GONE",
|
|
764
|
+
name: "Gone Error",
|
|
765
|
+
message: "Gone.",
|
|
766
|
+
uiMessage: "This resource is no longer available.",
|
|
767
|
+
type: "http"
|
|
768
|
+
},
|
|
769
|
+
lengthRequired: {
|
|
770
|
+
httpStatus: 411,
|
|
771
|
+
code: "LENGTH_REQUIRED",
|
|
772
|
+
name: "Length Required Error",
|
|
773
|
+
message: "Length required.",
|
|
774
|
+
uiMessage: "The request is missing required length information.",
|
|
775
|
+
type: "http"
|
|
776
|
+
},
|
|
777
|
+
preconditionFailed: {
|
|
778
|
+
httpStatus: 412,
|
|
779
|
+
code: "PRECONDITION_FAILED",
|
|
780
|
+
name: "Precondition Failed Error",
|
|
781
|
+
message: "Precondition failed.",
|
|
782
|
+
uiMessage: "A required condition was not met. Please try again.",
|
|
783
|
+
type: "http"
|
|
784
|
+
},
|
|
785
|
+
payloadTooLarge: {
|
|
786
|
+
httpStatus: 413,
|
|
787
|
+
code: "PAYLOAD_TOO_LARGE",
|
|
788
|
+
name: "Payload Too Large Error",
|
|
789
|
+
message: "Payload too large.",
|
|
790
|
+
uiMessage: "The request is too large. Please reduce the size and try again.",
|
|
791
|
+
type: "http"
|
|
792
|
+
},
|
|
793
|
+
uriTooLong: {
|
|
794
|
+
httpStatus: 414,
|
|
795
|
+
code: "URI_TOO_LONG",
|
|
796
|
+
name: "URI Too Long Error",
|
|
797
|
+
message: "URI too long.",
|
|
798
|
+
uiMessage: "The request URL is too long.",
|
|
799
|
+
type: "http"
|
|
800
|
+
},
|
|
801
|
+
unsupportedMediaType: {
|
|
802
|
+
httpStatus: 415,
|
|
803
|
+
code: "UNSUPPORTED_MEDIA_TYPE",
|
|
804
|
+
name: "Unsupported Media Type Error",
|
|
805
|
+
message: "Unsupported media type.",
|
|
806
|
+
uiMessage: "The file type is not supported.",
|
|
807
|
+
type: "http"
|
|
808
|
+
},
|
|
809
|
+
rangeNotSatisfiable: {
|
|
810
|
+
httpStatus: 416,
|
|
811
|
+
code: "RANGE_NOT_SATISFIABLE",
|
|
812
|
+
name: "Range Not Satisfiable Error",
|
|
813
|
+
message: "Range not satisfiable.",
|
|
814
|
+
uiMessage: "The requested range cannot be satisfied.",
|
|
815
|
+
type: "http"
|
|
816
|
+
},
|
|
817
|
+
expectationFailed: {
|
|
818
|
+
httpStatus: 417,
|
|
819
|
+
code: "EXPECTATION_FAILED",
|
|
820
|
+
name: "Expectation Failed Error",
|
|
821
|
+
message: "Expectation failed.",
|
|
822
|
+
uiMessage: "The server cannot meet the requirements of the request.",
|
|
823
|
+
type: "http"
|
|
824
|
+
},
|
|
825
|
+
imATeapot: {
|
|
826
|
+
httpStatus: 418,
|
|
827
|
+
code: "IM_A_TEAPOT",
|
|
828
|
+
name: "Im A Teapot Error",
|
|
829
|
+
message: "I'm a teapot.",
|
|
830
|
+
uiMessage: "I'm a teapot and cannot brew coffee.",
|
|
831
|
+
type: "http"
|
|
832
|
+
},
|
|
833
|
+
unprocessableEntity: {
|
|
834
|
+
httpStatus: 422,
|
|
835
|
+
code: "UNPROCESSABLE_ENTITY",
|
|
836
|
+
name: "Unprocessable Entity Error",
|
|
837
|
+
message: "Unprocessable entity.",
|
|
838
|
+
uiMessage: "The request contains invalid data. Please check your input.",
|
|
839
|
+
type: "http"
|
|
840
|
+
},
|
|
841
|
+
locked: {
|
|
842
|
+
httpStatus: 423,
|
|
843
|
+
code: "LOCKED",
|
|
844
|
+
name: "Locked Error",
|
|
845
|
+
message: "Locked.",
|
|
846
|
+
uiMessage: "This resource is locked and cannot be modified.",
|
|
847
|
+
type: "http"
|
|
848
|
+
},
|
|
849
|
+
failedDependency: {
|
|
850
|
+
httpStatus: 424,
|
|
851
|
+
code: "FAILED_DEPENDENCY",
|
|
852
|
+
name: "Failed Dependency Error",
|
|
853
|
+
message: "Failed dependency.",
|
|
854
|
+
uiMessage: "The request failed due to a dependency error.",
|
|
855
|
+
type: "http"
|
|
856
|
+
},
|
|
857
|
+
tooEarly: {
|
|
858
|
+
httpStatus: 425,
|
|
859
|
+
code: "TOO_EARLY",
|
|
860
|
+
name: "Too Early Error",
|
|
861
|
+
message: "Too early.",
|
|
862
|
+
uiMessage: "The request was sent too early. Please try again later.",
|
|
863
|
+
type: "http"
|
|
864
|
+
},
|
|
865
|
+
upgradeRequired: {
|
|
866
|
+
httpStatus: 426,
|
|
867
|
+
code: "UPGRADE_REQUIRED",
|
|
868
|
+
name: "Upgrade Required Error",
|
|
869
|
+
message: "Upgrade required.",
|
|
870
|
+
uiMessage: "Please upgrade to continue using this service.",
|
|
871
|
+
type: "http"
|
|
872
|
+
},
|
|
873
|
+
preconditionRequired: {
|
|
874
|
+
httpStatus: 428,
|
|
875
|
+
code: "PRECONDITION_REQUIRED",
|
|
876
|
+
name: "Precondition Required Error",
|
|
877
|
+
message: "Precondition required.",
|
|
878
|
+
uiMessage: "Required conditions are missing from the request.",
|
|
879
|
+
type: "http"
|
|
880
|
+
},
|
|
881
|
+
tooManyRequests: {
|
|
882
|
+
httpStatus: 429,
|
|
883
|
+
code: "TOO_MANY_REQUESTS",
|
|
884
|
+
name: "Too Many Requests Error",
|
|
885
|
+
message: "Too many requests.",
|
|
886
|
+
uiMessage: "You have made too many requests. Please wait and try again.",
|
|
887
|
+
type: "http"
|
|
888
|
+
},
|
|
889
|
+
requestHeaderFieldsTooLarge: {
|
|
890
|
+
httpStatus: 431,
|
|
891
|
+
code: "REQUEST_HEADER_FIELDS_TOO_LARGE",
|
|
892
|
+
name: "Request Header Fields Too Large Error",
|
|
893
|
+
message: "Request header fields too large.",
|
|
894
|
+
uiMessage: "The request headers are too large.",
|
|
895
|
+
type: "http"
|
|
896
|
+
},
|
|
897
|
+
unavailableForLegalReasons: {
|
|
898
|
+
httpStatus: 451,
|
|
899
|
+
code: "UNAVAILABLE_FOR_LEGAL_REASONS",
|
|
900
|
+
name: "Unavailable For Legal Reasons Error",
|
|
901
|
+
message: "Unavailable for legal reasons.",
|
|
902
|
+
uiMessage: "This content is unavailable for legal reasons.",
|
|
903
|
+
type: "http"
|
|
904
|
+
},
|
|
905
|
+
// 5xx Server Errors
|
|
906
|
+
internalServerError: {
|
|
907
|
+
httpStatus: 500,
|
|
908
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
909
|
+
name: "Internal Server Error",
|
|
910
|
+
message: "Internal server error.",
|
|
911
|
+
uiMessage: "An unexpected error occurred. Please try again later.",
|
|
912
|
+
type: "http"
|
|
913
|
+
},
|
|
914
|
+
notImplemented: {
|
|
915
|
+
httpStatus: 501,
|
|
916
|
+
code: "NOT_IMPLEMENTED",
|
|
917
|
+
name: "Not Implemented Error",
|
|
918
|
+
message: "Not implemented.",
|
|
919
|
+
uiMessage: "This feature is not yet available.",
|
|
920
|
+
type: "http"
|
|
921
|
+
},
|
|
922
|
+
badGateway: {
|
|
923
|
+
httpStatus: 502,
|
|
924
|
+
code: "BAD_GATEWAY",
|
|
925
|
+
name: "Bad Gateway Error",
|
|
926
|
+
message: "Bad gateway.",
|
|
927
|
+
uiMessage: "Unable to connect to the server. Please try again later.",
|
|
928
|
+
type: "http"
|
|
929
|
+
},
|
|
930
|
+
serviceUnavailable: {
|
|
931
|
+
httpStatus: 503,
|
|
932
|
+
code: "SERVICE_UNAVAILABLE",
|
|
933
|
+
name: "Service Unavailable Error",
|
|
934
|
+
message: "Service unavailable.",
|
|
935
|
+
uiMessage: "The service is temporarily unavailable. Please try again later.",
|
|
936
|
+
type: "http"
|
|
937
|
+
},
|
|
938
|
+
gatewayTimeout: {
|
|
939
|
+
httpStatus: 504,
|
|
940
|
+
code: "GATEWAY_TIMEOUT",
|
|
941
|
+
name: "Gateway Timeout Error",
|
|
942
|
+
message: "Gateway timeout.",
|
|
943
|
+
uiMessage: "The server took too long to respond. Please try again.",
|
|
944
|
+
type: "http"
|
|
945
|
+
},
|
|
946
|
+
httpVersionNotSupported: {
|
|
947
|
+
httpStatus: 505,
|
|
948
|
+
code: "HTTP_VERSION_NOT_SUPPORTED",
|
|
949
|
+
name: "HTTP Version Not Supported Error",
|
|
950
|
+
message: "HTTP version not supported.",
|
|
951
|
+
uiMessage: "Your browser version is not supported.",
|
|
952
|
+
type: "http"
|
|
953
|
+
},
|
|
954
|
+
variantAlsoNegotiates: {
|
|
955
|
+
httpStatus: 506,
|
|
956
|
+
code: "VARIANT_ALSO_NEGOTIATES",
|
|
957
|
+
name: "Variant Also Negotiates Error",
|
|
958
|
+
message: "Variant also negotiates.",
|
|
959
|
+
uiMessage: "The server has an internal configuration error.",
|
|
960
|
+
type: "http"
|
|
961
|
+
},
|
|
962
|
+
insufficientStorage: {
|
|
963
|
+
httpStatus: 507,
|
|
964
|
+
code: "INSUFFICIENT_STORAGE",
|
|
965
|
+
name: "Insufficient Storage Error",
|
|
966
|
+
message: "Insufficient storage.",
|
|
967
|
+
uiMessage: "The server has insufficient storage to complete the request.",
|
|
968
|
+
type: "http"
|
|
969
|
+
},
|
|
970
|
+
loopDetected: {
|
|
971
|
+
httpStatus: 508,
|
|
972
|
+
code: "LOOP_DETECTED",
|
|
973
|
+
name: "Loop Detected Error",
|
|
974
|
+
message: "Loop detected.",
|
|
975
|
+
uiMessage: "The server detected an infinite loop.",
|
|
976
|
+
type: "http"
|
|
977
|
+
},
|
|
978
|
+
notExtended: {
|
|
979
|
+
httpStatus: 510,
|
|
980
|
+
code: "NOT_EXTENDED",
|
|
981
|
+
name: "Not Extended Error",
|
|
982
|
+
message: "Not extended.",
|
|
983
|
+
uiMessage: "Additional extensions are required.",
|
|
984
|
+
type: "http"
|
|
985
|
+
},
|
|
986
|
+
networkAuthenticationRequired: {
|
|
987
|
+
httpStatus: 511,
|
|
988
|
+
code: "NETWORK_AUTHENTICATION_REQUIRED",
|
|
989
|
+
name: "Network Authentication Required Error",
|
|
990
|
+
message: "Network authentication required.",
|
|
991
|
+
uiMessage: "Network authentication is required to access this resource.",
|
|
992
|
+
type: "http"
|
|
993
|
+
}
|
|
1091
994
|
};
|
|
1092
995
|
|
|
1093
996
|
exports.ErrorX = ErrorX;
|
|
1094
|
-
exports.
|
|
997
|
+
exports.http = http;
|
|
1095
998
|
//# sourceMappingURL=index.cjs.map
|
|
1096
999
|
//# sourceMappingURL=index.cjs.map
|