@bombillazo/error-x 0.1.1 → 0.2.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/dist/index.cjs CHANGED
@@ -7,6 +7,32 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
  var safeStringify__default = /*#__PURE__*/_interopDefault(safeStringify);
8
8
 
9
9
  // src/error.ts
10
+
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
+ var ERROR_X_OPTION_FIELDS = [
23
+ "message",
24
+ "name",
25
+ "code",
26
+ "uiMessage",
27
+ "cause",
28
+ "metadata",
29
+ "actions",
30
+ "httpStatus",
31
+ "type"
32
+ ];
33
+
34
+ // src/error.ts
35
+ var acceptedFields = new Set(ERROR_X_OPTION_FIELDS);
10
36
  var ErrorX = class _ErrorX extends Error {
11
37
  /** Error identifier code, auto-generated from name if not provided */
12
38
  code;
@@ -18,47 +44,59 @@ var ErrorX = class _ErrorX extends Error {
18
44
  timestamp;
19
45
  /** Error actions for UI behavior and handling */
20
46
  actions;
47
+ /** HTTP status code (100-599) for HTTP-related errors */
48
+ httpStatus;
49
+ /** Error type for categorization */
50
+ type;
21
51
  /**
22
52
  * Creates a new ErrorX instance with enhanced error handling capabilities.
23
53
  *
24
- * @param options - Configuration options for the error (optional)
25
- * @param options.message - Technical error message (defaults to 'An error occurred')
26
- * @param options.name - Error type/name (defaults to 'Error')
27
- * @param options.code - Error identifier code (auto-generated from name if not provided)
28
- * @param options.uiMessage - User-friendly message (defaults to undefined)
29
- * @param options.cause - Original error that caused this error
30
- * @param options.metadata - Additional context data (defaults to undefined)
31
- * @param options.actions - Error actions for UI behavior and handling (defaults to undefined)
54
+ * @param messageOrOptions - Error message string, ErrorXOptions object, or any value to convert to ErrorX
55
+ * @param additionalOptions - Additional options when first parameter is a string (optional)
32
56
  *
33
57
  * @example
34
58
  * ```typescript
35
- * // Create with full options
36
- * const error = new ErrorX({
37
- * message: 'Database query failed',
59
+ * // Create with string message only
60
+ * const error1 = new ErrorX('Database query failed')
61
+ *
62
+ * // Create with string message and additional options
63
+ * const error2 = new ErrorX('Database query failed', {
38
64
  * name: 'DatabaseError',
39
65
  * code: 'DB_QUERY_FAILED',
40
66
  * uiMessage: 'Unable to load data. Please try again.',
41
- * metadata: { query: 'SELECT * FROM users', timeout: 5000 },
67
+ * metadata: { query: 'SELECT * FROM users', timeout: 5000 }
68
+ * })
69
+ *
70
+ * // Create with options object (backward compatible)
71
+ * const error3 = new ErrorX({
72
+ * message: 'Database query failed',
73
+ * name: 'DatabaseError',
74
+ * code: 'DB_QUERY_FAILED',
42
75
  * actions: [
43
- * {
44
- * action: 'notify',
45
- * payload: { targets: [HandlingTargets.TOAST] }
46
- * },
47
- * {
48
- * action: 'redirect',
49
- * payload: { redirectURL: '/dashboard', delay: 1000 }
50
- * }
76
+ * { action: 'notify', payload: { targets: [HandlingTargets.TOAST] } }
51
77
  * ]
52
78
  * })
53
79
  *
54
- * // Create with minimal options
55
- * const simpleError = new ErrorX({ message: 'Something failed' })
80
+ * // Create with unknown input (smart conversion)
81
+ * const apiError = { message: 'User not found', code: 404 }
82
+ * const error4 = new ErrorX(apiError)
56
83
  *
57
84
  * // Create with no options (uses defaults)
58
- * const defaultError = new ErrorX()
85
+ * const error5 = new ErrorX()
59
86
  * ```
60
87
  */
61
- constructor(options = {}) {
88
+ constructor(messageOrOptions, additionalOptions) {
89
+ let options = {};
90
+ if (typeof messageOrOptions === "string") {
91
+ options = {
92
+ message: messageOrOptions,
93
+ ...additionalOptions
94
+ };
95
+ } else if (_ErrorX.isErrorXOptions(messageOrOptions)) {
96
+ options = messageOrOptions;
97
+ } else if (messageOrOptions != null) {
98
+ options = _ErrorX.convertUnknownToOptions(messageOrOptions);
99
+ }
62
100
  const formattedMessage = _ErrorX.formatMessage(options.message);
63
101
  super(formattedMessage, { cause: options.cause });
64
102
  this.name = options.name ?? _ErrorX.getDefaultName();
@@ -66,6 +104,8 @@ var ErrorX = class _ErrorX extends Error {
66
104
  this.uiMessage = options.uiMessage;
67
105
  this.metadata = options.metadata;
68
106
  this.actions = options.actions;
107
+ this.httpStatus = _ErrorX.validateHttpStatus(options.httpStatus);
108
+ this.type = _ErrorX.validateType(options.type);
69
109
  this.timestamp = /* @__PURE__ */ new Date();
70
110
  if (options.cause instanceof Error) {
71
111
  this.stack = _ErrorX.preserveOriginalStack(options.cause, this);
@@ -83,6 +123,59 @@ var ErrorX = class _ErrorX extends Error {
83
123
  static getDefaultName() {
84
124
  return "Error";
85
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
+ }
158
+ /**
159
+ * Validates if an object is a valid ErrorXOptions object.
160
+ * Checks that the object only contains accepted ErrorXOptions fields.
161
+ *
162
+ * @param value - Value to check
163
+ * @returns True if value is a valid ErrorXOptions object
164
+ */
165
+ static isErrorXOptions(value) {
166
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
167
+ return false;
168
+ }
169
+ if (value instanceof Error) {
170
+ return false;
171
+ }
172
+ const obj = value;
173
+ const keys = Object.keys(obj);
174
+ if (keys.length === 0) {
175
+ return true;
176
+ }
177
+ return keys.every((key) => acceptedFields.has(key));
178
+ }
86
179
  /**
87
180
  * Generates a default error code from the error name.
88
181
  * Converts camelCase/PascalCase names to UPPER_SNAKE_CASE format.
@@ -215,7 +308,9 @@ var ErrorX = class _ErrorX extends Error {
215
308
  code: this.code,
216
309
  uiMessage: this.uiMessage,
217
310
  cause: this.cause,
218
- metadata: { ...this.metadata ?? {}, ...additionalMetadata }
311
+ metadata: { ...this.metadata ?? {}, ...additionalMetadata },
312
+ httpStatus: this.httpStatus,
313
+ type: this.type
219
314
  };
220
315
  if (this.actions) {
221
316
  options.actions = this.actions;
@@ -248,31 +343,15 @@ var ErrorX = class _ErrorX extends Error {
248
343
  return value instanceof _ErrorX;
249
344
  }
250
345
  /**
251
- * Converts unknown input into an ErrorX instance with intelligent property extraction.
346
+ * Converts unknown input into ErrorXOptions with intelligent property extraction.
252
347
  * Handles strings, regular Error objects, API response objects, and unknown values.
348
+ * This is a private helper method used by both the constructor and toErrorX.
253
349
  *
254
- * @param error - Value to convert to ErrorX
255
- * @returns ErrorX instance with extracted properties
256
- *
257
- * @example
258
- * ```typescript
259
- * // Convert string error
260
- * const error1 = ErrorX.toErrorX('Something went wrong')
261
- *
262
- * // Convert regular Error
263
- * const error2 = ErrorX.toErrorX(new Error('Database failed'))
264
- *
265
- * // Convert API response object
266
- * const apiError = {
267
- * message: 'User not found',
268
- * code: 'USER_404',
269
- * statusText: 'Not Found'
270
- * }
271
- * const error3 = ErrorX.toErrorX(apiError)
272
- * ```
350
+ * @param error - Value to convert to ErrorXOptions
351
+ * @returns ErrorXOptions object with extracted properties
352
+ * @internal
273
353
  */
274
- static toErrorX(error) {
275
- if (error instanceof _ErrorX) return error;
354
+ static convertUnknownToOptions(error) {
276
355
  let name = "";
277
356
  let message = "";
278
357
  let code = "";
@@ -280,6 +359,8 @@ var ErrorX = class _ErrorX extends Error {
280
359
  let cause;
281
360
  let metadata = {};
282
361
  let actions;
362
+ let httpStatus;
363
+ let type;
283
364
  if (error) {
284
365
  if (typeof error === "string") {
285
366
  message = error;
@@ -297,13 +378,29 @@ var ErrorX = class _ErrorX extends Error {
297
378
  else if ("info" in error && error.info) message = String(error.info);
298
379
  else if ("statusText" in error && error.statusText) message = String(error.statusText);
299
380
  else if ("error" in error && error.error) message = String(error.error);
300
- else if ("errorMessage" in error && error.errorMessage) message = String(error.errorMessage);
381
+ else if ("errorMessage" in error && error.errorMessage)
382
+ message = String(error.errorMessage);
301
383
  if ("code" in error && error.code) code = String(error.code);
302
384
  if ("uiMessage" in error && error.uiMessage) uiMessage = String(error.uiMessage);
303
385
  else if ("userMessage" in error && error.userMessage) uiMessage = String(error.userMessage);
304
386
  if ("actions" in error && Array.isArray(error.actions)) {
305
387
  actions = error.actions;
306
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
+ }
307
404
  metadata = { originalError: error };
308
405
  }
309
406
  }
@@ -316,6 +413,37 @@ var ErrorX = class _ErrorX extends Error {
316
413
  if (cause) options.cause = cause;
317
414
  if (Object.keys(metadata).length > 0) options.metadata = metadata;
318
415
  if (actions && actions.length > 0) options.actions = actions;
416
+ if (httpStatus) options.httpStatus = httpStatus;
417
+ if (type) options.type = type;
418
+ return options;
419
+ }
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) {
445
+ if (error instanceof _ErrorX) return error;
446
+ const options = _ErrorX.convertUnknownToOptions(error);
319
447
  return new _ErrorX(options);
320
448
  }
321
449
  /**
@@ -357,7 +485,9 @@ var ErrorX = class _ErrorX extends Error {
357
485
  name: this.name,
358
486
  code: this.code,
359
487
  uiMessage: this.uiMessage,
360
- cause: this.cause
488
+ cause: this.cause,
489
+ httpStatus: this.httpStatus,
490
+ type: this.type
361
491
  };
362
492
  if (this.metadata !== void 0) {
363
493
  options.metadata = this.metadata;
@@ -440,6 +570,12 @@ ${this.stack}`;
440
570
  const stringified = safeStringify__default.default(this.actions);
441
571
  serialized.actions = JSON.parse(stringified);
442
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
+ }
443
579
  if (this.stack) {
444
580
  serialized.stack = this.stack;
445
581
  }
@@ -490,7 +626,9 @@ ${this.stack}`;
490
626
  message: serialized.message,
491
627
  name: serialized.name,
492
628
  code: serialized.code,
493
- uiMessage: serialized.uiMessage
629
+ uiMessage: serialized.uiMessage,
630
+ httpStatus: serialized.httpStatus,
631
+ type: serialized.type
494
632
  };
495
633
  if (serialized.metadata !== void 0) {
496
634
  options.metadata = serialized.metadata;
@@ -516,19 +654,332 @@ ${this.stack}`;
516
654
  }
517
655
  };
518
656
 
519
- // src/types.ts
520
- var HandlingTargets = /* @__PURE__ */ ((HandlingTargets2) => {
521
- HandlingTargets2["MODAL"] = "modal";
522
- HandlingTargets2["TOAST"] = "toast";
523
- HandlingTargets2["INLINE"] = "inline";
524
- HandlingTargets2["BANNER"] = "banner";
525
- HandlingTargets2["CONSOLE"] = "console";
526
- HandlingTargets2["LOGGER"] = "logger";
527
- HandlingTargets2["NOTIFICATION"] = "notification";
528
- return HandlingTargets2;
529
- })(HandlingTargets || {});
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
+ };
530
980
 
531
981
  exports.ErrorX = ErrorX;
532
982
  exports.HandlingTargets = HandlingTargets;
983
+ exports.PRESETS = PRESETS;
533
984
  //# sourceMappingURL=index.cjs.map
534
985
  //# sourceMappingURL=index.cjs.map