@bombillazo/error-x 0.2.0 → 0.2.2
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 +175 -1
- package/dist/index.cjs +402 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +475 -1
- package/dist/index.d.ts +475 -1
- package/dist/index.js +402 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ A smart, isomorphic, and satisfying error library for TypeScript applications. P
|
|
|
17
17
|
- 📊 **Flexible metadata** for additional context
|
|
18
18
|
- 🎛️ **Error handling options** for UI behavior and application actions
|
|
19
19
|
- 📦 **Serialization/deserialization** support for network transfer and storage
|
|
20
|
+
- 🎨 **Pre-configured error presets** for common HTTP status codes (400-511)
|
|
20
21
|
|
|
21
22
|
## Installation
|
|
22
23
|
|
|
@@ -236,6 +237,179 @@ const error = new ErrorX({
|
|
|
236
237
|
})
|
|
237
238
|
```
|
|
238
239
|
|
|
240
|
+
## Error Presets
|
|
241
|
+
|
|
242
|
+
ErrorX provides pre-configured error templates for common scenarios, making it easy to create consistent, well-structured errors without repetition. All HTTP presets (400-511) are included with proper status codes, messages, and user-friendly text.
|
|
243
|
+
|
|
244
|
+
### Features
|
|
245
|
+
|
|
246
|
+
- ✅ **Pre-configured templates** with httpStatus, code, name, message, and uiMessage
|
|
247
|
+
- ✅ **Type-safe** with full TypeScript support
|
|
248
|
+
- ✅ **Fully customizable** via destructuring and override pattern
|
|
249
|
+
- ✅ **Categorized by type** - all HTTP presets include `type: 'http'` for easy filtering
|
|
250
|
+
- ✅ **User-friendly messages** included for all presets
|
|
251
|
+
|
|
252
|
+
### Usage Patterns
|
|
253
|
+
|
|
254
|
+
#### 1. Direct Usage
|
|
255
|
+
|
|
256
|
+
Use a preset as-is without modifications:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import { ErrorX, PRESETS } from '@bombillazo/error-x'
|
|
260
|
+
|
|
261
|
+
// Simple usage
|
|
262
|
+
throw new ErrorX(PRESETS.HTTP.NOT_FOUND)
|
|
263
|
+
// Result: 404 error with default message and UI message
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### 2. Override Specific Fields
|
|
267
|
+
|
|
268
|
+
Customize the error while keeping other preset values:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
throw new ErrorX({
|
|
272
|
+
...PRESETS.HTTP.NOT_FOUND,
|
|
273
|
+
message: 'User not found',
|
|
274
|
+
metadata: { userId: 123 }
|
|
275
|
+
})
|
|
276
|
+
// Result: 404 error with custom message but keeps httpStatus, code, name, uiMessage, type
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### 3. Add Metadata and Actions
|
|
280
|
+
|
|
281
|
+
Enhance presets with additional context and behaviors:
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
throw new ErrorX({
|
|
285
|
+
...PRESETS.HTTP.UNAUTHORIZED,
|
|
286
|
+
metadata: { attemptedAction: 'viewProfile', userId: 456 },
|
|
287
|
+
actions: [
|
|
288
|
+
{ action: 'logout', payload: { clearStorage: true } },
|
|
289
|
+
{ action: 'redirect', payload: { redirectURL: '/login' } }
|
|
290
|
+
]
|
|
291
|
+
})
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### 4. Add Error Cause
|
|
295
|
+
|
|
296
|
+
Chain errors by adding a cause:
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
try {
|
|
300
|
+
// some operation
|
|
301
|
+
} catch (originalError) {
|
|
302
|
+
throw new ErrorX({
|
|
303
|
+
...PRESETS.HTTP.INTERNAL_SERVER_ERROR,
|
|
304
|
+
cause: originalError,
|
|
305
|
+
metadata: { operation: 'database-query' }
|
|
306
|
+
})
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Available HTTP Presets
|
|
311
|
+
|
|
312
|
+
#### 4xx Client Errors
|
|
313
|
+
|
|
314
|
+
| Preset | Status | Description |
|
|
315
|
+
| ------ | ------ | ----------- |
|
|
316
|
+
| BAD_REQUEST | 400 | Invalid request data |
|
|
317
|
+
| UNAUTHORIZED | 401 | Authentication required |
|
|
318
|
+
| PAYMENT_REQUIRED | 402 | Payment required to access resource |
|
|
319
|
+
| FORBIDDEN | 403 | Insufficient permissions |
|
|
320
|
+
| NOT_FOUND | 404 | Resource not found |
|
|
321
|
+
| METHOD_NOT_ALLOWED | 405 | HTTP method not allowed |
|
|
322
|
+
| NOT_ACCEPTABLE | 406 | Requested format not supported |
|
|
323
|
+
| PROXY_AUTHENTICATION_REQUIRED | 407 | Proxy authentication required |
|
|
324
|
+
| REQUEST_TIMEOUT | 408 | Request took too long |
|
|
325
|
+
| CONFLICT | 409 | Resource conflict |
|
|
326
|
+
| GONE | 410 | Resource no longer available |
|
|
327
|
+
| LENGTH_REQUIRED | 411 | Missing length information |
|
|
328
|
+
| PRECONDITION_FAILED | 412 | Required condition not met |
|
|
329
|
+
| PAYLOAD_TOO_LARGE | 413 | Request payload too large |
|
|
330
|
+
| URI_TOO_LONG | 414 | Request URL too long |
|
|
331
|
+
| UNSUPPORTED_MEDIA_TYPE | 415 | File type not supported |
|
|
332
|
+
| RANGE_NOT_SATISFIABLE | 416 | Requested range cannot be satisfied |
|
|
333
|
+
| EXPECTATION_FAILED | 417 | Server cannot meet request requirements |
|
|
334
|
+
| IM_A_TEAPOT | 418 | I'm a teapot (RFC 2324) |
|
|
335
|
+
| UNPROCESSABLE_ENTITY | 422 | Validation failed |
|
|
336
|
+
| LOCKED | 423 | Resource is locked |
|
|
337
|
+
| FAILED_DEPENDENCY | 424 | Request failed due to dependency error |
|
|
338
|
+
| TOO_EARLY | 425 | Request sent too early |
|
|
339
|
+
| UPGRADE_REQUIRED | 426 | Upgrade required to continue |
|
|
340
|
+
| PRECONDITION_REQUIRED | 428 | Required conditions missing |
|
|
341
|
+
| TOO_MANY_REQUESTS | 429 | Rate limit exceeded |
|
|
342
|
+
| REQUEST_HEADER_FIELDS_TOO_LARGE | 431 | Request headers too large |
|
|
343
|
+
| UNAVAILABLE_FOR_LEGAL_REASONS | 451 | Content unavailable for legal reasons |
|
|
344
|
+
|
|
345
|
+
#### 5xx Server Errors
|
|
346
|
+
|
|
347
|
+
| Preset | Status | Description |
|
|
348
|
+
| ------ | ------ | ----------- |
|
|
349
|
+
| INTERNAL_SERVER_ERROR | 500 | Unexpected server error |
|
|
350
|
+
| NOT_IMPLEMENTED | 501 | Feature not implemented |
|
|
351
|
+
| BAD_GATEWAY | 502 | Upstream server error |
|
|
352
|
+
| SERVICE_UNAVAILABLE | 503 | Service temporarily down |
|
|
353
|
+
| GATEWAY_TIMEOUT | 504 | Upstream timeout |
|
|
354
|
+
| HTTP_VERSION_NOT_SUPPORTED | 505 | HTTP version not supported |
|
|
355
|
+
| VARIANT_ALSO_NEGOTIATES | 506 | Internal configuration error |
|
|
356
|
+
| INSUFFICIENT_STORAGE | 507 | Insufficient storage |
|
|
357
|
+
| LOOP_DETECTED | 508 | Infinite loop detected |
|
|
358
|
+
| NOT_EXTENDED | 510 | Additional extensions required |
|
|
359
|
+
| NETWORK_AUTHENTICATION_REQUIRED | 511 | Network authentication required |
|
|
360
|
+
|
|
361
|
+
### Real-World Examples
|
|
362
|
+
|
|
363
|
+
#### API Endpoint
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { ErrorX, PRESETS } from '@bombillazo/error-x'
|
|
367
|
+
|
|
368
|
+
app.get('/users/:id', async (req, res) => {
|
|
369
|
+
const user = await db.users.findById(req.params.id)
|
|
370
|
+
|
|
371
|
+
if (!user) {
|
|
372
|
+
throw new ErrorX({
|
|
373
|
+
...PRESETS.HTTP.NOT_FOUND,
|
|
374
|
+
message: 'User not found',
|
|
375
|
+
metadata: { userId: req.params.id }
|
|
376
|
+
})
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
res.json(user)
|
|
380
|
+
})
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### Authentication Middleware
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
const requireAuth = (req, res, next) => {
|
|
387
|
+
if (!req.user) {
|
|
388
|
+
throw new ErrorX({
|
|
389
|
+
...PRESETS.HTTP.UNAUTHORIZED,
|
|
390
|
+
actions: [
|
|
391
|
+
{ action: 'redirect', payload: { redirectURL: '/login' } }
|
|
392
|
+
]
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
next()
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
#### Rate Limiting
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
if (isRateLimited(req.ip)) {
|
|
403
|
+
throw new ErrorX({
|
|
404
|
+
...PRESETS.HTTP.TOO_MANY_REQUESTS,
|
|
405
|
+
metadata: {
|
|
406
|
+
ip: req.ip,
|
|
407
|
+
retryAfter: 60
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
239
413
|
## Smart Features
|
|
240
414
|
|
|
241
415
|
### Auto Code Generation
|
|
@@ -246,7 +420,7 @@ Error codes are automatically generated from the error name:
|
|
|
246
420
|
new ErrorX({ message: 'Failed', name: 'DatabaseError' })
|
|
247
421
|
// code: 'DATABASE_ERROR'
|
|
248
422
|
|
|
249
|
-
new ErrorX({ message: 'Failed', name: 'userAuthError' })
|
|
423
|
+
new ErrorX({ message: 'Failed', name: 'userAuthError' })
|
|
250
424
|
// code: 'USER_AUTH_ERROR'
|
|
251
425
|
|
|
252
426
|
new ErrorX({ message: 'Failed', name: 'API Timeout' })
|
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,9 @@ var ERROR_X_OPTION_FIELDS = [
|
|
|
26
26
|
"uiMessage",
|
|
27
27
|
"cause",
|
|
28
28
|
"metadata",
|
|
29
|
-
"actions"
|
|
29
|
+
"actions",
|
|
30
|
+
"httpStatus",
|
|
31
|
+
"type"
|
|
30
32
|
];
|
|
31
33
|
|
|
32
34
|
// src/error.ts
|
|
@@ -42,6 +44,10 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
42
44
|
timestamp;
|
|
43
45
|
/** Error actions for UI behavior and handling */
|
|
44
46
|
actions;
|
|
47
|
+
/** HTTP status code (100-599) for HTTP-related errors */
|
|
48
|
+
httpStatus;
|
|
49
|
+
/** Error type for categorization */
|
|
50
|
+
type;
|
|
45
51
|
/**
|
|
46
52
|
* Creates a new ErrorX instance with enhanced error handling capabilities.
|
|
47
53
|
*
|
|
@@ -98,6 +104,8 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
98
104
|
this.uiMessage = options.uiMessage;
|
|
99
105
|
this.metadata = options.metadata;
|
|
100
106
|
this.actions = options.actions;
|
|
107
|
+
this.httpStatus = _ErrorX.validateHttpStatus(options.httpStatus);
|
|
108
|
+
this.type = _ErrorX.validateType(options.type);
|
|
101
109
|
this.timestamp = /* @__PURE__ */ new Date();
|
|
102
110
|
if (options.cause instanceof Error) {
|
|
103
111
|
this.stack = _ErrorX.preserveOriginalStack(options.cause, this);
|
|
@@ -115,6 +123,38 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
115
123
|
static getDefaultName() {
|
|
116
124
|
return "Error";
|
|
117
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Validates HTTP status code to ensure it's within valid range (100-599)
|
|
128
|
+
*
|
|
129
|
+
* @param status - Status code to validate
|
|
130
|
+
* @returns Valid status code or undefined if invalid/not provided
|
|
131
|
+
*/
|
|
132
|
+
static validateHttpStatus(status) {
|
|
133
|
+
if (status === void 0 || status === null) {
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
const statusNum = Number(status);
|
|
137
|
+
if (Number.isNaN(statusNum) || statusNum < 100 || statusNum > 599) {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
return Math.floor(statusNum);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Validates and normalizes the type field
|
|
144
|
+
*
|
|
145
|
+
* @param type - Type value to validate
|
|
146
|
+
* @returns Validated type string or undefined if invalid/empty
|
|
147
|
+
*/
|
|
148
|
+
static validateType(type) {
|
|
149
|
+
if (type === void 0 || type === null) {
|
|
150
|
+
return void 0;
|
|
151
|
+
}
|
|
152
|
+
const typeStr = String(type).trim();
|
|
153
|
+
if (typeStr === "") {
|
|
154
|
+
return void 0;
|
|
155
|
+
}
|
|
156
|
+
return typeStr;
|
|
157
|
+
}
|
|
118
158
|
/**
|
|
119
159
|
* Validates if an object is a valid ErrorXOptions object.
|
|
120
160
|
* Checks that the object only contains accepted ErrorXOptions fields.
|
|
@@ -268,7 +308,9 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
268
308
|
code: this.code,
|
|
269
309
|
uiMessage: this.uiMessage,
|
|
270
310
|
cause: this.cause,
|
|
271
|
-
metadata: { ...this.metadata ?? {}, ...additionalMetadata }
|
|
311
|
+
metadata: { ...this.metadata ?? {}, ...additionalMetadata },
|
|
312
|
+
httpStatus: this.httpStatus,
|
|
313
|
+
type: this.type
|
|
272
314
|
};
|
|
273
315
|
if (this.actions) {
|
|
274
316
|
options.actions = this.actions;
|
|
@@ -317,6 +359,8 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
317
359
|
let cause;
|
|
318
360
|
let metadata = {};
|
|
319
361
|
let actions;
|
|
362
|
+
let httpStatus;
|
|
363
|
+
let type;
|
|
320
364
|
if (error) {
|
|
321
365
|
if (typeof error === "string") {
|
|
322
366
|
message = error;
|
|
@@ -334,13 +378,29 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
334
378
|
else if ("info" in error && error.info) message = String(error.info);
|
|
335
379
|
else if ("statusText" in error && error.statusText) message = String(error.statusText);
|
|
336
380
|
else if ("error" in error && error.error) message = String(error.error);
|
|
337
|
-
else if ("errorMessage" in error && error.errorMessage)
|
|
381
|
+
else if ("errorMessage" in error && error.errorMessage)
|
|
382
|
+
message = String(error.errorMessage);
|
|
338
383
|
if ("code" in error && error.code) code = String(error.code);
|
|
339
384
|
if ("uiMessage" in error && error.uiMessage) uiMessage = String(error.uiMessage);
|
|
340
385
|
else if ("userMessage" in error && error.userMessage) uiMessage = String(error.userMessage);
|
|
341
386
|
if ("actions" in error && Array.isArray(error.actions)) {
|
|
342
387
|
actions = error.actions;
|
|
343
388
|
}
|
|
389
|
+
let _httpStatus;
|
|
390
|
+
if ("httpStatus" in error) {
|
|
391
|
+
_httpStatus = error.httpStatus;
|
|
392
|
+
} else if ("status" in error) {
|
|
393
|
+
_httpStatus = error.status;
|
|
394
|
+
} else if ("statusCode" in error) {
|
|
395
|
+
_httpStatus = error.statusCode;
|
|
396
|
+
}
|
|
397
|
+
if (_httpStatus !== void 0 && _httpStatus !== null) {
|
|
398
|
+
const num = typeof _httpStatus === "number" ? _httpStatus : Number(_httpStatus);
|
|
399
|
+
httpStatus = _ErrorX.validateHttpStatus(num);
|
|
400
|
+
}
|
|
401
|
+
if ("type" in error && error.type) {
|
|
402
|
+
type = _ErrorX.validateType(String(error.type));
|
|
403
|
+
}
|
|
344
404
|
metadata = { originalError: error };
|
|
345
405
|
}
|
|
346
406
|
}
|
|
@@ -353,6 +413,8 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
353
413
|
if (cause) options.cause = cause;
|
|
354
414
|
if (Object.keys(metadata).length > 0) options.metadata = metadata;
|
|
355
415
|
if (actions && actions.length > 0) options.actions = actions;
|
|
416
|
+
if (httpStatus) options.httpStatus = httpStatus;
|
|
417
|
+
if (type) options.type = type;
|
|
356
418
|
return options;
|
|
357
419
|
}
|
|
358
420
|
/**
|
|
@@ -423,7 +485,9 @@ var ErrorX = class _ErrorX extends Error {
|
|
|
423
485
|
name: this.name,
|
|
424
486
|
code: this.code,
|
|
425
487
|
uiMessage: this.uiMessage,
|
|
426
|
-
cause: this.cause
|
|
488
|
+
cause: this.cause,
|
|
489
|
+
httpStatus: this.httpStatus,
|
|
490
|
+
type: this.type
|
|
427
491
|
};
|
|
428
492
|
if (this.metadata !== void 0) {
|
|
429
493
|
options.metadata = this.metadata;
|
|
@@ -506,6 +570,12 @@ ${this.stack}`;
|
|
|
506
570
|
const stringified = safeStringify__default.default(this.actions);
|
|
507
571
|
serialized.actions = JSON.parse(stringified);
|
|
508
572
|
}
|
|
573
|
+
if (this.httpStatus !== void 0) {
|
|
574
|
+
serialized.httpStatus = this.httpStatus;
|
|
575
|
+
}
|
|
576
|
+
if (this.type !== void 0) {
|
|
577
|
+
serialized.type = this.type;
|
|
578
|
+
}
|
|
509
579
|
if (this.stack) {
|
|
510
580
|
serialized.stack = this.stack;
|
|
511
581
|
}
|
|
@@ -556,7 +626,9 @@ ${this.stack}`;
|
|
|
556
626
|
message: serialized.message,
|
|
557
627
|
name: serialized.name,
|
|
558
628
|
code: serialized.code,
|
|
559
|
-
uiMessage: serialized.uiMessage
|
|
629
|
+
uiMessage: serialized.uiMessage,
|
|
630
|
+
httpStatus: serialized.httpStatus,
|
|
631
|
+
type: serialized.type
|
|
560
632
|
};
|
|
561
633
|
if (serialized.metadata !== void 0) {
|
|
562
634
|
options.metadata = serialized.metadata;
|
|
@@ -582,7 +654,332 @@ ${this.stack}`;
|
|
|
582
654
|
}
|
|
583
655
|
};
|
|
584
656
|
|
|
657
|
+
// src/presets.ts
|
|
658
|
+
var PRESETS = {
|
|
659
|
+
/**
|
|
660
|
+
* HTTP error presets for common HTTP status codes.
|
|
661
|
+
* Includes both 4xx client errors and 5xx server errors.
|
|
662
|
+
*/
|
|
663
|
+
HTTP: {
|
|
664
|
+
// 4xx Client Errors
|
|
665
|
+
BAD_REQUEST: {
|
|
666
|
+
httpStatus: 400,
|
|
667
|
+
code: "BAD_REQUEST",
|
|
668
|
+
name: "BadRequestError",
|
|
669
|
+
message: "Bad request",
|
|
670
|
+
uiMessage: "The request could not be processed. Please check your input and try again.",
|
|
671
|
+
type: "http"
|
|
672
|
+
},
|
|
673
|
+
UNAUTHORIZED: {
|
|
674
|
+
httpStatus: 401,
|
|
675
|
+
code: "UNAUTHORIZED",
|
|
676
|
+
name: "UnauthorizedError",
|
|
677
|
+
message: "Unauthorized",
|
|
678
|
+
uiMessage: "Authentication required. Please log in to continue.",
|
|
679
|
+
type: "http"
|
|
680
|
+
},
|
|
681
|
+
PAYMENT_REQUIRED: {
|
|
682
|
+
httpStatus: 402,
|
|
683
|
+
code: "PAYMENT_REQUIRED",
|
|
684
|
+
name: "PaymentRequiredError",
|
|
685
|
+
message: "Payment required",
|
|
686
|
+
uiMessage: "Payment is required to access this resource.",
|
|
687
|
+
type: "http"
|
|
688
|
+
},
|
|
689
|
+
FORBIDDEN: {
|
|
690
|
+
httpStatus: 403,
|
|
691
|
+
code: "FORBIDDEN",
|
|
692
|
+
name: "ForbiddenError",
|
|
693
|
+
message: "Forbidden",
|
|
694
|
+
uiMessage: "You do not have permission to access this resource.",
|
|
695
|
+
type: "http"
|
|
696
|
+
},
|
|
697
|
+
NOT_FOUND: {
|
|
698
|
+
httpStatus: 404,
|
|
699
|
+
code: "NOT_FOUND",
|
|
700
|
+
name: "NotFoundError",
|
|
701
|
+
message: "Not found",
|
|
702
|
+
uiMessage: "The requested resource could not be found.",
|
|
703
|
+
type: "http"
|
|
704
|
+
},
|
|
705
|
+
METHOD_NOT_ALLOWED: {
|
|
706
|
+
httpStatus: 405,
|
|
707
|
+
code: "METHOD_NOT_ALLOWED",
|
|
708
|
+
name: "MethodNotAllowedError",
|
|
709
|
+
message: "Method not allowed",
|
|
710
|
+
uiMessage: "This action is not allowed for the requested resource.",
|
|
711
|
+
type: "http"
|
|
712
|
+
},
|
|
713
|
+
NOT_ACCEPTABLE: {
|
|
714
|
+
httpStatus: 406,
|
|
715
|
+
code: "NOT_ACCEPTABLE",
|
|
716
|
+
name: "NotAcceptableError",
|
|
717
|
+
message: "Not acceptable",
|
|
718
|
+
uiMessage: "The requested format is not supported.",
|
|
719
|
+
type: "http"
|
|
720
|
+
},
|
|
721
|
+
PROXY_AUTHENTICATION_REQUIRED: {
|
|
722
|
+
httpStatus: 407,
|
|
723
|
+
code: "PROXY_AUTHENTICATION_REQUIRED",
|
|
724
|
+
name: "ProxyAuthenticationRequiredError",
|
|
725
|
+
message: "Proxy authentication required",
|
|
726
|
+
uiMessage: "Proxy authentication is required to access this resource.",
|
|
727
|
+
type: "http"
|
|
728
|
+
},
|
|
729
|
+
REQUEST_TIMEOUT: {
|
|
730
|
+
httpStatus: 408,
|
|
731
|
+
code: "REQUEST_TIMEOUT",
|
|
732
|
+
name: "RequestTimeoutError",
|
|
733
|
+
message: "Request timeout",
|
|
734
|
+
uiMessage: "The request took too long to complete. Please try again.",
|
|
735
|
+
type: "http"
|
|
736
|
+
},
|
|
737
|
+
CONFLICT: {
|
|
738
|
+
httpStatus: 409,
|
|
739
|
+
code: "CONFLICT",
|
|
740
|
+
name: "ConflictError",
|
|
741
|
+
message: "Conflict",
|
|
742
|
+
uiMessage: "The request conflicts with the current state. Please refresh and try again.",
|
|
743
|
+
type: "http"
|
|
744
|
+
},
|
|
745
|
+
GONE: {
|
|
746
|
+
httpStatus: 410,
|
|
747
|
+
code: "GONE",
|
|
748
|
+
name: "GoneError",
|
|
749
|
+
message: "Gone",
|
|
750
|
+
uiMessage: "This resource is no longer available.",
|
|
751
|
+
type: "http"
|
|
752
|
+
},
|
|
753
|
+
LENGTH_REQUIRED: {
|
|
754
|
+
httpStatus: 411,
|
|
755
|
+
code: "LENGTH_REQUIRED",
|
|
756
|
+
name: "LengthRequiredError",
|
|
757
|
+
message: "Length required",
|
|
758
|
+
uiMessage: "The request is missing required length information.",
|
|
759
|
+
type: "http"
|
|
760
|
+
},
|
|
761
|
+
PRECONDITION_FAILED: {
|
|
762
|
+
httpStatus: 412,
|
|
763
|
+
code: "PRECONDITION_FAILED",
|
|
764
|
+
name: "PreconditionFailedError",
|
|
765
|
+
message: "Precondition failed",
|
|
766
|
+
uiMessage: "A required condition was not met. Please try again.",
|
|
767
|
+
type: "http"
|
|
768
|
+
},
|
|
769
|
+
PAYLOAD_TOO_LARGE: {
|
|
770
|
+
httpStatus: 413,
|
|
771
|
+
code: "PAYLOAD_TOO_LARGE",
|
|
772
|
+
name: "PayloadTooLargeError",
|
|
773
|
+
message: "Payload too large",
|
|
774
|
+
uiMessage: "The request is too large. Please reduce the size and try again.",
|
|
775
|
+
type: "http"
|
|
776
|
+
},
|
|
777
|
+
URI_TOO_LONG: {
|
|
778
|
+
httpStatus: 414,
|
|
779
|
+
code: "URI_TOO_LONG",
|
|
780
|
+
name: "URITooLongError",
|
|
781
|
+
message: "URI too long",
|
|
782
|
+
uiMessage: "The request URL is too long.",
|
|
783
|
+
type: "http"
|
|
784
|
+
},
|
|
785
|
+
UNSUPPORTED_MEDIA_TYPE: {
|
|
786
|
+
httpStatus: 415,
|
|
787
|
+
code: "UNSUPPORTED_MEDIA_TYPE",
|
|
788
|
+
name: "UnsupportedMediaTypeError",
|
|
789
|
+
message: "Unsupported media type",
|
|
790
|
+
uiMessage: "The file type is not supported.",
|
|
791
|
+
type: "http"
|
|
792
|
+
},
|
|
793
|
+
RANGE_NOT_SATISFIABLE: {
|
|
794
|
+
httpStatus: 416,
|
|
795
|
+
code: "RANGE_NOT_SATISFIABLE",
|
|
796
|
+
name: "RangeNotSatisfiableError",
|
|
797
|
+
message: "Range not satisfiable",
|
|
798
|
+
uiMessage: "The requested range cannot be satisfied.",
|
|
799
|
+
type: "http"
|
|
800
|
+
},
|
|
801
|
+
EXPECTATION_FAILED: {
|
|
802
|
+
httpStatus: 417,
|
|
803
|
+
code: "EXPECTATION_FAILED",
|
|
804
|
+
name: "ExpectationFailedError",
|
|
805
|
+
message: "Expectation failed",
|
|
806
|
+
uiMessage: "The server cannot meet the requirements of the request.",
|
|
807
|
+
type: "http"
|
|
808
|
+
},
|
|
809
|
+
IM_A_TEAPOT: {
|
|
810
|
+
httpStatus: 418,
|
|
811
|
+
code: "IM_A_TEAPOT",
|
|
812
|
+
name: "ImATeapotError",
|
|
813
|
+
message: "I'm a teapot",
|
|
814
|
+
uiMessage: "I'm a teapot and cannot brew coffee.",
|
|
815
|
+
type: "http"
|
|
816
|
+
},
|
|
817
|
+
UNPROCESSABLE_ENTITY: {
|
|
818
|
+
httpStatus: 422,
|
|
819
|
+
code: "UNPROCESSABLE_ENTITY",
|
|
820
|
+
name: "UnprocessableEntityError",
|
|
821
|
+
message: "Unprocessable entity",
|
|
822
|
+
uiMessage: "The request contains invalid data. Please check your input.",
|
|
823
|
+
type: "http"
|
|
824
|
+
},
|
|
825
|
+
LOCKED: {
|
|
826
|
+
httpStatus: 423,
|
|
827
|
+
code: "LOCKED",
|
|
828
|
+
name: "LockedError",
|
|
829
|
+
message: "Locked",
|
|
830
|
+
uiMessage: "This resource is locked and cannot be modified.",
|
|
831
|
+
type: "http"
|
|
832
|
+
},
|
|
833
|
+
FAILED_DEPENDENCY: {
|
|
834
|
+
httpStatus: 424,
|
|
835
|
+
code: "FAILED_DEPENDENCY",
|
|
836
|
+
name: "FailedDependencyError",
|
|
837
|
+
message: "Failed dependency",
|
|
838
|
+
uiMessage: "The request failed due to a dependency error.",
|
|
839
|
+
type: "http"
|
|
840
|
+
},
|
|
841
|
+
TOO_EARLY: {
|
|
842
|
+
httpStatus: 425,
|
|
843
|
+
code: "TOO_EARLY",
|
|
844
|
+
name: "TooEarlyError",
|
|
845
|
+
message: "Too early",
|
|
846
|
+
uiMessage: "The request was sent too early. Please try again later.",
|
|
847
|
+
type: "http"
|
|
848
|
+
},
|
|
849
|
+
UPGRADE_REQUIRED: {
|
|
850
|
+
httpStatus: 426,
|
|
851
|
+
code: "UPGRADE_REQUIRED",
|
|
852
|
+
name: "UpgradeRequiredError",
|
|
853
|
+
message: "Upgrade required",
|
|
854
|
+
uiMessage: "Please upgrade to continue using this service.",
|
|
855
|
+
type: "http"
|
|
856
|
+
},
|
|
857
|
+
PRECONDITION_REQUIRED: {
|
|
858
|
+
httpStatus: 428,
|
|
859
|
+
code: "PRECONDITION_REQUIRED",
|
|
860
|
+
name: "PreconditionRequiredError",
|
|
861
|
+
message: "Precondition required",
|
|
862
|
+
uiMessage: "Required conditions are missing from the request.",
|
|
863
|
+
type: "http"
|
|
864
|
+
},
|
|
865
|
+
TOO_MANY_REQUESTS: {
|
|
866
|
+
httpStatus: 429,
|
|
867
|
+
code: "TOO_MANY_REQUESTS",
|
|
868
|
+
name: "TooManyRequestsError",
|
|
869
|
+
message: "Too many requests",
|
|
870
|
+
uiMessage: "You have made too many requests. Please wait and try again.",
|
|
871
|
+
type: "http"
|
|
872
|
+
},
|
|
873
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: {
|
|
874
|
+
httpStatus: 431,
|
|
875
|
+
code: "REQUEST_HEADER_FIELDS_TOO_LARGE",
|
|
876
|
+
name: "RequestHeaderFieldsTooLargeError",
|
|
877
|
+
message: "Request header fields too large",
|
|
878
|
+
uiMessage: "The request headers are too large.",
|
|
879
|
+
type: "http"
|
|
880
|
+
},
|
|
881
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: {
|
|
882
|
+
httpStatus: 451,
|
|
883
|
+
code: "UNAVAILABLE_FOR_LEGAL_REASONS",
|
|
884
|
+
name: "UnavailableForLegalReasonsError",
|
|
885
|
+
message: "Unavailable for legal reasons",
|
|
886
|
+
uiMessage: "This content is unavailable for legal reasons.",
|
|
887
|
+
type: "http"
|
|
888
|
+
},
|
|
889
|
+
// 5xx Server Errors
|
|
890
|
+
INTERNAL_SERVER_ERROR: {
|
|
891
|
+
httpStatus: 500,
|
|
892
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
893
|
+
name: "InternalServerError",
|
|
894
|
+
message: "Internal server error",
|
|
895
|
+
uiMessage: "An unexpected error occurred. Please try again later.",
|
|
896
|
+
type: "http"
|
|
897
|
+
},
|
|
898
|
+
NOT_IMPLEMENTED: {
|
|
899
|
+
httpStatus: 501,
|
|
900
|
+
code: "NOT_IMPLEMENTED",
|
|
901
|
+
name: "NotImplementedError",
|
|
902
|
+
message: "Not implemented",
|
|
903
|
+
uiMessage: "This feature is not yet available.",
|
|
904
|
+
type: "http"
|
|
905
|
+
},
|
|
906
|
+
BAD_GATEWAY: {
|
|
907
|
+
httpStatus: 502,
|
|
908
|
+
code: "BAD_GATEWAY",
|
|
909
|
+
name: "BadGatewayError",
|
|
910
|
+
message: "Bad gateway",
|
|
911
|
+
uiMessage: "Unable to connect to the server. Please try again later.",
|
|
912
|
+
type: "http"
|
|
913
|
+
},
|
|
914
|
+
SERVICE_UNAVAILABLE: {
|
|
915
|
+
httpStatus: 503,
|
|
916
|
+
code: "SERVICE_UNAVAILABLE",
|
|
917
|
+
name: "ServiceUnavailableError",
|
|
918
|
+
message: "Service unavailable",
|
|
919
|
+
uiMessage: "The service is temporarily unavailable. Please try again later.",
|
|
920
|
+
type: "http"
|
|
921
|
+
},
|
|
922
|
+
GATEWAY_TIMEOUT: {
|
|
923
|
+
httpStatus: 504,
|
|
924
|
+
code: "GATEWAY_TIMEOUT",
|
|
925
|
+
name: "GatewayTimeoutError",
|
|
926
|
+
message: "Gateway timeout",
|
|
927
|
+
uiMessage: "The server took too long to respond. Please try again.",
|
|
928
|
+
type: "http"
|
|
929
|
+
},
|
|
930
|
+
HTTP_VERSION_NOT_SUPPORTED: {
|
|
931
|
+
httpStatus: 505,
|
|
932
|
+
code: "HTTP_VERSION_NOT_SUPPORTED",
|
|
933
|
+
name: "HTTPVersionNotSupportedError",
|
|
934
|
+
message: "HTTP version not supported",
|
|
935
|
+
uiMessage: "Your browser version is not supported.",
|
|
936
|
+
type: "http"
|
|
937
|
+
},
|
|
938
|
+
VARIANT_ALSO_NEGOTIATES: {
|
|
939
|
+
httpStatus: 506,
|
|
940
|
+
code: "VARIANT_ALSO_NEGOTIATES",
|
|
941
|
+
name: "VariantAlsoNegotiatesError",
|
|
942
|
+
message: "Variant also negotiates",
|
|
943
|
+
uiMessage: "The server has an internal configuration error.",
|
|
944
|
+
type: "http"
|
|
945
|
+
},
|
|
946
|
+
INSUFFICIENT_STORAGE: {
|
|
947
|
+
httpStatus: 507,
|
|
948
|
+
code: "INSUFFICIENT_STORAGE",
|
|
949
|
+
name: "InsufficientStorageError",
|
|
950
|
+
message: "Insufficient storage",
|
|
951
|
+
uiMessage: "The server has insufficient storage to complete the request.",
|
|
952
|
+
type: "http"
|
|
953
|
+
},
|
|
954
|
+
LOOP_DETECTED: {
|
|
955
|
+
httpStatus: 508,
|
|
956
|
+
code: "LOOP_DETECTED",
|
|
957
|
+
name: "LoopDetectedError",
|
|
958
|
+
message: "Loop detected",
|
|
959
|
+
uiMessage: "The server detected an infinite loop.",
|
|
960
|
+
type: "http"
|
|
961
|
+
},
|
|
962
|
+
NOT_EXTENDED: {
|
|
963
|
+
httpStatus: 510,
|
|
964
|
+
code: "NOT_EXTENDED",
|
|
965
|
+
name: "NotExtendedError",
|
|
966
|
+
message: "Not extended",
|
|
967
|
+
uiMessage: "Additional extensions are required.",
|
|
968
|
+
type: "http"
|
|
969
|
+
},
|
|
970
|
+
NETWORK_AUTHENTICATION_REQUIRED: {
|
|
971
|
+
httpStatus: 511,
|
|
972
|
+
code: "NETWORK_AUTHENTICATION_REQUIRED",
|
|
973
|
+
name: "NetworkAuthenticationRequiredError",
|
|
974
|
+
message: "Network authentication required",
|
|
975
|
+
uiMessage: "Network authentication is required to access this resource.",
|
|
976
|
+
type: "http"
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
|
|
585
981
|
exports.ErrorX = ErrorX;
|
|
586
982
|
exports.HandlingTargets = HandlingTargets;
|
|
983
|
+
exports.PRESETS = PRESETS;
|
|
587
984
|
//# sourceMappingURL=index.cjs.map
|
|
588
985
|
//# sourceMappingURL=index.cjs.map
|