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