@bombillazo/error-x 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +235 -371
- package/dist/index.cjs +497 -478
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +499 -608
- package/dist/index.d.ts +499 -608
- package/dist/index.js +497 -477
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,167 +2,22 @@
|
|
|
2
2
|
* Metadata object containing additional context information for an error.
|
|
3
3
|
* Can store any key-value pairs to provide extra debugging or business context.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Users can use metadata to store application-specific behavior instructions if needed:
|
|
6
6
|
* ```typescript
|
|
7
|
-
* const metadata
|
|
7
|
+
* const metadata = {
|
|
8
8
|
* userId: 123,
|
|
9
9
|
* operation: 'fetchUser',
|
|
10
|
-
* retryCount: 3
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
type ErrorMetadata = Record<string, any>;
|
|
17
|
-
/**
|
|
18
|
-
* Predefined display targets for error notifications and UI feedback.
|
|
19
|
-
* These enum values provide consistent, type-safe options for where errors should be displayed.
|
|
20
|
-
*
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
declare enum HandlingTargets {
|
|
24
|
-
MODAL = "modal",
|
|
25
|
-
TOAST = "toast",
|
|
26
|
-
INLINE = "inline",
|
|
27
|
-
BANNER = "banner",
|
|
28
|
-
CONSOLE = "console",
|
|
29
|
-
LOGGER = "logger",
|
|
30
|
-
NOTIFICATION = "notification"
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Display target type that allows both predefined enum values and custom strings.
|
|
34
|
-
* This enables flexibility for custom UI components while providing standard options.
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* // Using predefined enum values
|
|
39
|
-
* targets: [HandlingTargets.MODAL, HandlingTargets.TOAST]
|
|
40
|
-
*
|
|
41
|
-
* // Using custom strings
|
|
42
|
-
* targets: ['custom-sidebar', 'my-notification-center']
|
|
43
|
-
*
|
|
44
|
-
* // Mixing both
|
|
45
|
-
* targets: [HandlingTargets.MODAL, 'custom-popup', HandlingTargets.CONSOLE]
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
type HandlingTarget = HandlingTargets | string;
|
|
51
|
-
/**
|
|
52
|
-
* Action to display notifications in specified UI targets.
|
|
53
|
-
* Used to notify applications to handle error messages through the indicated display mechanisms.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* {
|
|
58
|
-
* action: 'notify',
|
|
59
|
-
* payload: {
|
|
60
|
-
* targets: [HandlingTargets.TOAST, 'custom-sidebar'],
|
|
61
|
-
* title: 'Error occurred',
|
|
62
|
-
* duration: 5000
|
|
63
|
-
* }
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
type NotifyAction = {
|
|
70
|
-
action: 'notify';
|
|
71
|
-
payload: {
|
|
72
|
-
targets: HandlingTarget[];
|
|
73
|
-
[key: string]: any;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Action to log out the current user when an error occurs.
|
|
78
|
-
* Useful for authentication errors or session expiration.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* {
|
|
83
|
-
* action: 'logout',
|
|
84
|
-
* payload: {
|
|
85
|
-
* clearStorage: true,
|
|
86
|
-
* redirectURL: '/login'
|
|
87
|
-
* }
|
|
88
|
-
* }
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
type LogoutAction = {
|
|
94
|
-
action: 'logout';
|
|
95
|
-
payload?: {
|
|
96
|
-
[key: string]: any;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Action to redirect the user to a different URL when an error occurs.
|
|
101
|
-
* Commonly used for navigation after authentication errors or access denied scenarios.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```typescript
|
|
105
|
-
* {
|
|
106
|
-
* action: 'redirect',
|
|
107
|
-
* payload: {
|
|
108
|
-
* redirectURL: '/login',
|
|
109
|
-
* delay: 2000,
|
|
110
|
-
* replace: true,
|
|
111
|
-
* }
|
|
10
|
+
* retryCount: 3,
|
|
11
|
+
* // Application-specific behavior can be stored here:
|
|
12
|
+
* shouldNotify: true,
|
|
13
|
+
* notifyTargets: ['toast', 'banner'],
|
|
14
|
+
* redirectTo: '/login'
|
|
112
15
|
* }
|
|
113
16
|
* ```
|
|
114
17
|
*
|
|
115
18
|
* @public
|
|
116
19
|
*/
|
|
117
|
-
type
|
|
118
|
-
action: 'redirect';
|
|
119
|
-
payload: {
|
|
120
|
-
redirectURL: string;
|
|
121
|
-
[key: string]: any;
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Custom action type for application-specific actions.
|
|
126
|
-
* This type is essential for proper TypeScript discrimination in the ErrorAction union.
|
|
127
|
-
* Without this, TypeScript cannot properly distinguish between predefined and custom actions.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* ```typescript
|
|
131
|
-
* {
|
|
132
|
-
* action: 'custom',
|
|
133
|
-
* payload: {
|
|
134
|
-
* type: 'analytics',
|
|
135
|
-
* event: 'error_occurred',
|
|
136
|
-
* category: 'authentication',
|
|
137
|
-
* severity: 'high'
|
|
138
|
-
* }
|
|
139
|
-
* }
|
|
140
|
-
*
|
|
141
|
-
* {
|
|
142
|
-
* action: 'custom',
|
|
143
|
-
* payload: {
|
|
144
|
-
* type: 'show-modal',
|
|
145
|
-
* modalId: 'error-modal',
|
|
146
|
-
* title: 'Error',
|
|
147
|
-
* message: 'Something went wrong'
|
|
148
|
-
* }
|
|
149
|
-
* }
|
|
150
|
-
* ```
|
|
151
|
-
*
|
|
152
|
-
* @public
|
|
153
|
-
*/
|
|
154
|
-
type CustomAction = {
|
|
155
|
-
action: 'custom';
|
|
156
|
-
payload?: Record<string, any>;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Union type of all possible error actions.
|
|
160
|
-
* Includes predefined actions (NotifyAction, LogoutAction, RedirectAction)
|
|
161
|
-
* and CustomAction for application-specific actions.
|
|
162
|
-
*
|
|
163
|
-
* @public
|
|
164
|
-
*/
|
|
165
|
-
type ErrorAction = NotifyAction | LogoutAction | RedirectAction | CustomAction;
|
|
20
|
+
type ErrorXMetadata = Record<string, unknown>;
|
|
166
21
|
/**
|
|
167
22
|
* Configuration options for creating an ErrorX instance.
|
|
168
23
|
* All properties are optional with sensible defaults.
|
|
@@ -178,6 +33,10 @@ type ErrorAction = NotifyAction | LogoutAction | RedirectAction | CustomAction;
|
|
|
178
33
|
* // ✅ Works - object literal
|
|
179
34
|
* const opts = { message: 'Error' }
|
|
180
35
|
* new ErrorX(opts)
|
|
36
|
+
*
|
|
37
|
+
* // ✅ Works - with type-safe metadata
|
|
38
|
+
* type MyMeta = { userId: number; action: string };
|
|
39
|
+
* new ErrorX<MyMeta>({ metadata: { userId: 123, action: 'login' } })
|
|
181
40
|
* ```
|
|
182
41
|
*
|
|
183
42
|
* If ErrorXOptions were a class, you would need to instantiate it:
|
|
@@ -192,25 +51,43 @@ type ErrorAction = NotifyAction | LogoutAction | RedirectAction | CustomAction;
|
|
|
192
51
|
*
|
|
193
52
|
* @public
|
|
194
53
|
*/
|
|
195
|
-
type ErrorXOptions = {
|
|
54
|
+
type ErrorXOptions<TMetadata extends ErrorXMetadata = ErrorXMetadata> = {
|
|
196
55
|
/** Technical error message (default: 'An error occurred') */
|
|
197
56
|
message?: string;
|
|
198
57
|
/** Error type/name (default: 'Error') */
|
|
199
58
|
name?: string;
|
|
200
59
|
/** Error identifier code (auto-generated from name if not provided) */
|
|
201
60
|
code?: string | number;
|
|
202
|
-
/** User-friendly message for UI display
|
|
61
|
+
/** User-friendly message for UI display */
|
|
203
62
|
uiMessage?: string | undefined;
|
|
204
63
|
/** Original error that caused this error (preserves error chain) */
|
|
205
64
|
cause?: Error | unknown;
|
|
206
|
-
/** Additional context and debugging information
|
|
207
|
-
metadata?:
|
|
208
|
-
/**
|
|
209
|
-
actions?: ErrorAction[];
|
|
210
|
-
/** HTTP status code (100-599) for HTTP-related errors (default: undefined) */
|
|
65
|
+
/** Additional context and debugging information */
|
|
66
|
+
metadata?: TMetadata | undefined;
|
|
67
|
+
/** HTTP status code (100-599) for HTTP-related errors */
|
|
211
68
|
httpStatus?: number | undefined;
|
|
212
69
|
/** Error type for categorization */
|
|
213
70
|
type?: string | undefined;
|
|
71
|
+
/** Source URL related to the error (API endpoint, page URL, resource URL) */
|
|
72
|
+
sourceUrl?: string | undefined;
|
|
73
|
+
/** Documentation URL for this specific error */
|
|
74
|
+
docsUrl?: string | undefined;
|
|
75
|
+
/** Where the error originated (service name, module, component) */
|
|
76
|
+
source?: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Simplified representation of an error cause for serialization.
|
|
80
|
+
* Used to store error chain information without circular references.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
type ErrorXCause = {
|
|
85
|
+
/** Error message */
|
|
86
|
+
message: string;
|
|
87
|
+
/** Error name (optional) */
|
|
88
|
+
name?: string;
|
|
89
|
+
/** Stack trace (optional) */
|
|
90
|
+
stack?: string;
|
|
214
91
|
};
|
|
215
92
|
/**
|
|
216
93
|
* JSON-serializable representation of an ErrorX instance.
|
|
@@ -226,21 +103,20 @@ type ErrorXOptions = {
|
|
|
226
103
|
* stack: 'Error: Authentication failed.\n at login (auth.ts:42:15)',
|
|
227
104
|
* metadata: { userId: 123, loginAttempt: 3 },
|
|
228
105
|
* timestamp: '2024-01-15T10:30:45.123Z',
|
|
229
|
-
* actions: [
|
|
230
|
-
* { action: 'logout', payload: { clearStorage: true } }
|
|
231
|
-
* ],
|
|
232
106
|
* cause: {
|
|
233
107
|
* name: 'NetworkError',
|
|
234
108
|
* message: 'Request timeout.',
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
109
|
+
* stack: '...'
|
|
110
|
+
* },
|
|
111
|
+
* sourceUrl: 'https://api.example.com/auth',
|
|
112
|
+
* docsUrl: 'https://docs.example.com/errors#auth-failed',
|
|
113
|
+
* source: 'auth-service'
|
|
238
114
|
* }
|
|
239
115
|
* ```
|
|
240
116
|
*
|
|
241
117
|
* @public
|
|
242
118
|
*/
|
|
243
|
-
type
|
|
119
|
+
type ErrorXSerialized = {
|
|
244
120
|
/** Error type/name */
|
|
245
121
|
name: string;
|
|
246
122
|
/** Technical error message */
|
|
@@ -252,24 +128,58 @@ type SerializableError = {
|
|
|
252
128
|
/** Stack trace (optional) */
|
|
253
129
|
stack?: string;
|
|
254
130
|
/** Additional context and debugging information */
|
|
255
|
-
metadata:
|
|
131
|
+
metadata: ErrorXMetadata | undefined;
|
|
256
132
|
/** ISO timestamp when error was created */
|
|
257
133
|
timestamp: string;
|
|
258
|
-
/**
|
|
259
|
-
|
|
260
|
-
/** Serialized cause error (for error chaining) */
|
|
261
|
-
cause?: SerializableError;
|
|
134
|
+
/** Simplified cause error (for error chaining) */
|
|
135
|
+
cause?: ErrorXCause;
|
|
262
136
|
/** HTTP status code for HTTP-related errors */
|
|
263
137
|
httpStatus?: number;
|
|
264
138
|
/** Error type for categorization */
|
|
265
139
|
type?: string;
|
|
140
|
+
/** Source URL related to the error */
|
|
141
|
+
sourceUrl?: string;
|
|
142
|
+
/** Documentation URL for this error */
|
|
143
|
+
docsUrl?: string;
|
|
144
|
+
/** Where the error originated */
|
|
145
|
+
source?: string;
|
|
266
146
|
};
|
|
267
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Configuration interface for ErrorX global settings
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
*/
|
|
153
|
+
interface ErrorXConfig {
|
|
154
|
+
/** Default source identifier for all errors (e.g., service name, module name) */
|
|
155
|
+
source?: string;
|
|
156
|
+
/** Base URL for error documentation */
|
|
157
|
+
docsBaseURL?: string;
|
|
158
|
+
/** Mapping of error codes to documentation paths */
|
|
159
|
+
docsMap?: Record<string, string>;
|
|
160
|
+
/**
|
|
161
|
+
* Control stack trace cleaning behavior
|
|
162
|
+
* - true: Enable automatic stack trace cleaning (default)
|
|
163
|
+
* - false: Disable stack trace cleaning entirely
|
|
164
|
+
* - string[]: Custom patterns to match and remove from stack traces
|
|
165
|
+
*/
|
|
166
|
+
cleanStack?: boolean | string[];
|
|
167
|
+
}
|
|
268
168
|
/**
|
|
269
169
|
* Enhanced Error class with rich metadata, type-safe error handling, and intelligent error conversion.
|
|
270
170
|
*
|
|
271
171
|
* @example
|
|
272
172
|
* ```typescript
|
|
173
|
+
* // Configure globally (optional)
|
|
174
|
+
* ErrorX.configure({
|
|
175
|
+
* source: 'my-service',
|
|
176
|
+
* docsBaseURL: 'https://docs.example.com',
|
|
177
|
+
* docsMap: {
|
|
178
|
+
* 'AUTH_FAILED': 'errors/authentication',
|
|
179
|
+
* 'DB_ERROR': 'errors/database'
|
|
180
|
+
* }
|
|
181
|
+
* })
|
|
182
|
+
*
|
|
273
183
|
* // Basic usage
|
|
274
184
|
* const error = new ErrorX({ message: 'Database connection failed' })
|
|
275
185
|
*
|
|
@@ -281,68 +191,103 @@ type SerializableError = {
|
|
|
281
191
|
* uiMessage: 'Please check your credentials',
|
|
282
192
|
* metadata: { userId: 123, loginAttempt: 3 }
|
|
283
193
|
* })
|
|
194
|
+
*
|
|
195
|
+
* // With type-safe metadata
|
|
196
|
+
* type MyMetadata = { userId: number; action: string };
|
|
197
|
+
* const error = new ErrorX<MyMetadata>({
|
|
198
|
+
* message: 'Action failed',
|
|
199
|
+
* metadata: { userId: 123, action: 'delete' }
|
|
200
|
+
* })
|
|
201
|
+
* // error.metadata?.userId is typed as number
|
|
284
202
|
* ```
|
|
285
203
|
*
|
|
286
204
|
* @public
|
|
287
205
|
*/
|
|
288
|
-
declare class ErrorX extends Error {
|
|
206
|
+
declare class ErrorX<TMetadata extends ErrorXMetadata = ErrorXMetadata> extends Error {
|
|
207
|
+
/** Global configuration for all ErrorX instances */
|
|
208
|
+
private static _config;
|
|
289
209
|
/** Error identifier code, auto-generated from name if not provided */
|
|
290
|
-
|
|
210
|
+
code: string;
|
|
291
211
|
/** User-friendly message suitable for display in UI */
|
|
292
|
-
|
|
212
|
+
uiMessage: string | undefined;
|
|
293
213
|
/** Additional context and metadata associated with the error */
|
|
294
|
-
|
|
214
|
+
metadata: TMetadata | undefined;
|
|
295
215
|
/** Timestamp when the error was created */
|
|
296
|
-
|
|
297
|
-
/** Error actions for UI behavior and handling */
|
|
298
|
-
readonly actions: ErrorAction[] | undefined;
|
|
216
|
+
timestamp: Date;
|
|
299
217
|
/** HTTP status code (100-599) for HTTP-related errors */
|
|
300
|
-
|
|
218
|
+
httpStatus: number | undefined;
|
|
301
219
|
/** Error type for categorization */
|
|
302
|
-
|
|
220
|
+
type: string | undefined;
|
|
221
|
+
/** Source URL related to the error (API endpoint, page URL, resource URL) */
|
|
222
|
+
sourceUrl: string | undefined;
|
|
223
|
+
/** Documentation URL for this specific error */
|
|
224
|
+
docsUrl: string | undefined;
|
|
225
|
+
/** Where the error originated (service name, module, component) */
|
|
226
|
+
source: string | undefined;
|
|
303
227
|
/**
|
|
304
228
|
* Creates a new ErrorX instance with enhanced error handling capabilities.
|
|
305
229
|
*
|
|
306
|
-
* @param messageOrOptions - Error message string
|
|
307
|
-
* @param additionalOptions - Additional options when first parameter is a string (optional)
|
|
230
|
+
* @param messageOrOptions - Error message string or ErrorXOptions object (optional)
|
|
308
231
|
*
|
|
309
232
|
* @example
|
|
310
233
|
* ```typescript
|
|
234
|
+
* // Create with default message
|
|
235
|
+
* const error1 = new ErrorX()
|
|
236
|
+
*
|
|
311
237
|
* // Create with string message only
|
|
312
|
-
* const
|
|
238
|
+
* const error2 = new ErrorX('Database query failed')
|
|
313
239
|
*
|
|
314
|
-
* // Create with
|
|
315
|
-
* const
|
|
240
|
+
* // Create with options object
|
|
241
|
+
* const error3 = new ErrorX({
|
|
242
|
+
* message: 'Database query failed',
|
|
316
243
|
* name: 'DatabaseError',
|
|
317
244
|
* code: 'DB_QUERY_FAILED',
|
|
318
245
|
* uiMessage: 'Unable to load data. Please try again.',
|
|
319
246
|
* metadata: { query: 'SELECT * FROM users', timeout: 5000 }
|
|
320
247
|
* })
|
|
321
248
|
*
|
|
322
|
-
* //
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* actions: [
|
|
328
|
-
* { action: 'notify', payload: { targets: [HandlingTargets.TOAST] } }
|
|
329
|
-
* ]
|
|
249
|
+
* // With type-safe metadata
|
|
250
|
+
* type MyMeta = { userId: number };
|
|
251
|
+
* const error4 = new ErrorX<MyMeta>({
|
|
252
|
+
* message: 'User action failed',
|
|
253
|
+
* metadata: { userId: 123 }
|
|
330
254
|
* })
|
|
331
255
|
*
|
|
332
|
-
* //
|
|
256
|
+
* // For converting unknown errors, use ErrorX.from()
|
|
333
257
|
* const apiError = { message: 'User not found', code: 404 }
|
|
334
|
-
* const
|
|
335
|
-
*
|
|
336
|
-
* // Create with no options (uses defaults)
|
|
337
|
-
* const error5 = new ErrorX()
|
|
258
|
+
* const error5 = ErrorX.from(apiError)
|
|
338
259
|
* ```
|
|
339
260
|
*/
|
|
340
|
-
constructor(messageOrOptions?: string | ErrorXOptions
|
|
261
|
+
constructor(messageOrOptions?: string | ErrorXOptions<TMetadata>);
|
|
341
262
|
/**
|
|
342
263
|
* Returns the default error name.
|
|
343
264
|
* @returns Default error name 'Error'
|
|
344
265
|
*/
|
|
345
266
|
private static getDefaultName;
|
|
267
|
+
/**
|
|
268
|
+
* Configure global ErrorX settings.
|
|
269
|
+
* This method allows you to set defaults for all ErrorX instances.
|
|
270
|
+
*
|
|
271
|
+
* @param config - Configuration object
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* ErrorX.configure({
|
|
276
|
+
* source: 'my-api-service',
|
|
277
|
+
* docsBaseURL: 'https://docs.example.com/errors',
|
|
278
|
+
* docsMap: {
|
|
279
|
+
* 'AUTH_FAILED': 'authentication-errors',
|
|
280
|
+
* 'DB_ERROR': 'database-errors'
|
|
281
|
+
* }
|
|
282
|
+
* })
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
static configure(config: ErrorXConfig): void;
|
|
286
|
+
/**
|
|
287
|
+
* Get the current global configuration.
|
|
288
|
+
* Returns null if no configuration has been set.
|
|
289
|
+
*/
|
|
290
|
+
static getConfig(): ErrorXConfig | null;
|
|
346
291
|
/**
|
|
347
292
|
* Validates HTTP status code to ensure it's within valid range (100-599)
|
|
348
293
|
*
|
|
@@ -412,21 +357,6 @@ declare class ErrorX extends Error {
|
|
|
412
357
|
* ```
|
|
413
358
|
*/
|
|
414
359
|
private static processErrorStack;
|
|
415
|
-
/**
|
|
416
|
-
* Formats error messages with proper capitalization and punctuation.
|
|
417
|
-
* Ensures consistent message formatting across all ErrorX instances.
|
|
418
|
-
*
|
|
419
|
-
* @param message - Raw error message to format (optional)
|
|
420
|
-
* @returns Formatted message with proper capitalization and punctuation
|
|
421
|
-
*
|
|
422
|
-
* @example
|
|
423
|
-
* ```typescript
|
|
424
|
-
* formatMessage('database connection failed') // 'Database connection failed.'
|
|
425
|
-
* formatMessage('user not found. please check credentials') // 'User not found. Please check credentials.'
|
|
426
|
-
* formatMessage() // 'An error occurred'
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
private static formatMessage;
|
|
430
360
|
/**
|
|
431
361
|
* Creates a new ErrorX instance with additional metadata merged with existing metadata.
|
|
432
362
|
* The original error properties are preserved while extending the metadata.
|
|
@@ -448,7 +378,7 @@ declare class ErrorX extends Error {
|
|
|
448
378
|
* // Result: metadata = { endpoint: '/users', retryCount: 3, userId: 123 }
|
|
449
379
|
* ```
|
|
450
380
|
*/
|
|
451
|
-
withMetadata(additionalMetadata:
|
|
381
|
+
withMetadata(additionalMetadata: Partial<TMetadata>): ErrorX<TMetadata>;
|
|
452
382
|
/**
|
|
453
383
|
* Type guard that checks if a value is an ErrorX instance.
|
|
454
384
|
*
|
|
@@ -467,7 +397,7 @@ declare class ErrorX extends Error {
|
|
|
467
397
|
* }
|
|
468
398
|
* ```
|
|
469
399
|
*/
|
|
470
|
-
static isErrorX(value: unknown): value is ErrorX
|
|
400
|
+
static isErrorX<TMetadata extends ErrorXMetadata = ErrorXMetadata>(value: unknown): value is ErrorX<TMetadata>;
|
|
471
401
|
/**
|
|
472
402
|
* Converts unknown input into ErrorXOptions with intelligent property extraction.
|
|
473
403
|
* Handles strings, regular Error objects, API response objects, and unknown values.
|
|
@@ -488,10 +418,10 @@ declare class ErrorX extends Error {
|
|
|
488
418
|
* @example
|
|
489
419
|
* ```typescript
|
|
490
420
|
* // Convert string error
|
|
491
|
-
* const error1 = ErrorX.
|
|
421
|
+
* const error1 = ErrorX.from('Something went wrong')
|
|
492
422
|
*
|
|
493
423
|
* // Convert regular Error
|
|
494
|
-
* const error2 = ErrorX.
|
|
424
|
+
* const error2 = ErrorX.from(new Error('Database failed'))
|
|
495
425
|
*
|
|
496
426
|
* // Convert API response object
|
|
497
427
|
* const apiError = {
|
|
@@ -499,26 +429,13 @@ declare class ErrorX extends Error {
|
|
|
499
429
|
* code: 'USER_404',
|
|
500
430
|
* statusText: 'Not Found'
|
|
501
431
|
* }
|
|
502
|
-
* const error3 = ErrorX.
|
|
503
|
-
* ```
|
|
504
|
-
*/
|
|
505
|
-
static toErrorX(error: unknown): ErrorX;
|
|
506
|
-
/**
|
|
507
|
-
* Public wrapper for processing error stack traces with delimiter.
|
|
508
|
-
* Delegates to the private processErrorStack method for implementation.
|
|
509
|
-
*
|
|
510
|
-
* @param error - Error whose stack to process
|
|
511
|
-
* @param delimiter - String to search for in stack lines
|
|
512
|
-
* @returns Processed stack trace starting after the delimiter
|
|
513
|
-
*
|
|
514
|
-
* @example
|
|
515
|
-
* ```typescript
|
|
516
|
-
* const error = new Error('Something failed')
|
|
517
|
-
* const cleanStack = ErrorX.processStack(error, 'my-app-entry')
|
|
518
|
-
* // Returns stack trace starting after the line containing 'my-app-entry'
|
|
432
|
+
* const error3 = ErrorX.from(apiError)
|
|
519
433
|
* ```
|
|
520
434
|
*/
|
|
521
|
-
static
|
|
435
|
+
static from<TMetadata extends ErrorXMetadata = ErrorXMetadata>(error: ErrorX<TMetadata>): ErrorX<TMetadata>;
|
|
436
|
+
static from(error: Error): ErrorX;
|
|
437
|
+
static from(error: string): ErrorX;
|
|
438
|
+
static from(error: unknown): ErrorX;
|
|
522
439
|
/**
|
|
523
440
|
* Creates a new ErrorX instance with cleaned stack trace using the specified delimiter.
|
|
524
441
|
* Returns the same instance if no delimiter is provided or no stack is available.
|
|
@@ -533,7 +450,7 @@ declare class ErrorX extends Error {
|
|
|
533
450
|
* // Returns new ErrorX with stack trace starting after 'database-layer'
|
|
534
451
|
* ```
|
|
535
452
|
*/
|
|
536
|
-
cleanStackTrace(delimiter?: string): ErrorX
|
|
453
|
+
cleanStackTrace(delimiter?: string): ErrorX<TMetadata>;
|
|
537
454
|
/**
|
|
538
455
|
* Converts the ErrorX instance to a detailed string representation.
|
|
539
456
|
* Includes error name, message, code, timestamp, metadata, and stack trace.
|
|
@@ -572,7 +489,7 @@ declare class ErrorX extends Error {
|
|
|
572
489
|
* // Can be safely passed to JSON.stringify() or sent over network
|
|
573
490
|
* ```
|
|
574
491
|
*/
|
|
575
|
-
toJSON():
|
|
492
|
+
toJSON(): ErrorXSerialized;
|
|
576
493
|
/**
|
|
577
494
|
* Deserializes a JSON object back into an ErrorX instance.
|
|
578
495
|
* Recursively reconstructs the error chain and restores all properties.
|
|
@@ -595,54 +512,41 @@ declare class ErrorX extends Error {
|
|
|
595
512
|
* // Fully restored ErrorX instance with all properties
|
|
596
513
|
* ```
|
|
597
514
|
*/
|
|
598
|
-
static fromJSON(serialized:
|
|
515
|
+
static fromJSON<TMetadata extends ErrorXMetadata = ErrorXMetadata>(serialized: ErrorXSerialized): ErrorX<TMetadata>;
|
|
599
516
|
}
|
|
600
517
|
|
|
601
518
|
/**
|
|
602
|
-
*
|
|
519
|
+
* HTTP error presets for common HTTP status codes.
|
|
603
520
|
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* - **Type-safe** with TypeScript support
|
|
607
|
-
* - **Fully customizable** via destructuring and override pattern
|
|
608
|
-
* - **User-friendly messages** included for all presets
|
|
609
|
-
* - **Categorized by type** - all HTTP presets include `type: 'http'`
|
|
610
|
-
*
|
|
611
|
-
* ## Available Categories
|
|
612
|
-
* - **HTTP**: Common HTTP status codes (4xx client errors, 5xx server errors)
|
|
521
|
+
* These presets provide pre-configured error options for standard HTTP error responses,
|
|
522
|
+
* including appropriate status codes, error codes, names, messages (sentence case), and user-friendly UI messages.
|
|
613
523
|
*
|
|
614
524
|
* ## Usage Patterns
|
|
615
525
|
*
|
|
616
|
-
* ### 1.
|
|
617
|
-
*
|
|
526
|
+
* ### 1. Use Preset Directly
|
|
527
|
+
* Create an error with all preset values:
|
|
618
528
|
* ```typescript
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
* throw new ErrorX(PRESETS.HTTP.NOT_FOUND)
|
|
622
|
-
* // Result: 404 error with default message and UI message
|
|
529
|
+
* throw new ErrorX(http.notFound)
|
|
530
|
+
* // Result: 404 error with message "Not found.", code, name, uiMessage, and type
|
|
623
531
|
* ```
|
|
624
532
|
*
|
|
625
533
|
* ### 2. Override Specific Fields
|
|
626
534
|
* Customize the error while keeping other preset values:
|
|
627
535
|
* ```typescript
|
|
628
536
|
* throw new ErrorX({
|
|
629
|
-
* ...
|
|
537
|
+
* ...http.notFound,
|
|
630
538
|
* message: 'User not found',
|
|
631
539
|
* metadata: { userId: 123 }
|
|
632
540
|
* })
|
|
633
541
|
* // Result: 404 error with custom message but keeps httpStatus, code, name, uiMessage, type
|
|
634
542
|
* ```
|
|
635
543
|
*
|
|
636
|
-
* ### 3. Add Metadata
|
|
637
|
-
* Enhance presets with additional context
|
|
544
|
+
* ### 3. Add Metadata
|
|
545
|
+
* Enhance presets with additional context:
|
|
638
546
|
* ```typescript
|
|
639
547
|
* throw new ErrorX({
|
|
640
|
-
* ...
|
|
641
|
-
* metadata: { attemptedAction: 'viewProfile', userId: 456 }
|
|
642
|
-
* actions: [
|
|
643
|
-
* { action: 'logout', payload: { clearStorage: true } },
|
|
644
|
-
* { action: 'redirect', payload: { redirectURL: '/login' } }
|
|
645
|
-
* ]
|
|
548
|
+
* ...http.unauthorized,
|
|
549
|
+
* metadata: { attemptedAction: 'viewProfile', userId: 456 }
|
|
646
550
|
* })
|
|
647
551
|
* ```
|
|
648
552
|
*
|
|
@@ -653,7 +557,7 @@ declare class ErrorX extends Error {
|
|
|
653
557
|
* // some operation
|
|
654
558
|
* } catch (originalError) {
|
|
655
559
|
* throw new ErrorX({
|
|
656
|
-
* ...
|
|
560
|
+
* ...http.internalServerError,
|
|
657
561
|
* cause: originalError,
|
|
658
562
|
* metadata: { operation: 'database-query' }
|
|
659
563
|
* })
|
|
@@ -663,33 +567,31 @@ declare class ErrorX extends Error {
|
|
|
663
567
|
* ## Common HTTP Presets
|
|
664
568
|
*
|
|
665
569
|
* ### 4xx Client Errors
|
|
666
|
-
* - `
|
|
667
|
-
* - `
|
|
668
|
-
* - `
|
|
669
|
-
* - `
|
|
670
|
-
* - `
|
|
671
|
-
* - `
|
|
672
|
-
* - `
|
|
673
|
-
* - `
|
|
570
|
+
* - `badRequest` (400) - Invalid request data
|
|
571
|
+
* - `unauthorized` (401) - Authentication required
|
|
572
|
+
* - `forbidden` (403) - Insufficient permissions
|
|
573
|
+
* - `notFound` (404) - Resource not found
|
|
574
|
+
* - `methodNotAllowed` (405) - HTTP method not allowed
|
|
575
|
+
* - `conflict` (409) - Resource conflict
|
|
576
|
+
* - `unprocessableEntity` (422) - Validation failed
|
|
577
|
+
* - `tooManyRequests` (429) - Rate limit exceeded
|
|
674
578
|
*
|
|
675
579
|
* ### 5xx Server Errors
|
|
676
|
-
* - `
|
|
677
|
-
* - `
|
|
678
|
-
* - `
|
|
679
|
-
* - `
|
|
680
|
-
* - `
|
|
580
|
+
* - `internalServerError` (500) - Unexpected server error
|
|
581
|
+
* - `notImplemented` (501) - Feature not implemented
|
|
582
|
+
* - `badGateway` (502) - Upstream server error
|
|
583
|
+
* - `serviceUnavailable` (503) - Service temporarily down
|
|
584
|
+
* - `gatewayTimeout` (504) - Upstream timeout
|
|
681
585
|
*
|
|
682
586
|
* @example
|
|
683
587
|
* ```typescript
|
|
684
|
-
* import { ErrorX, PRESETS } from '@bombillazo/error-x'
|
|
685
|
-
*
|
|
686
588
|
* // API endpoint example
|
|
687
589
|
* app.get('/users/:id', async (req, res) => {
|
|
688
590
|
* const user = await db.users.findById(req.params.id)
|
|
689
591
|
*
|
|
690
592
|
* if (!user) {
|
|
691
593
|
* throw new ErrorX({
|
|
692
|
-
* ...
|
|
594
|
+
* ...http.notFound,
|
|
693
595
|
* message: 'User not found',
|
|
694
596
|
* metadata: { userId: req.params.id }
|
|
695
597
|
* })
|
|
@@ -701,12 +603,7 @@ declare class ErrorX extends Error {
|
|
|
701
603
|
* // Authentication middleware example
|
|
702
604
|
* const requireAuth = (req, res, next) => {
|
|
703
605
|
* if (!req.user) {
|
|
704
|
-
* throw new ErrorX(
|
|
705
|
-
* ...PRESETS.HTTP.UNAUTHORIZED,
|
|
706
|
-
* actions: [
|
|
707
|
-
* { action: 'redirect', payload: { redirectURL: '/login' } }
|
|
708
|
-
* ]
|
|
709
|
-
* })
|
|
606
|
+
* throw new ErrorX(http.unauthorized)
|
|
710
607
|
* }
|
|
711
608
|
* next()
|
|
712
609
|
* }
|
|
@@ -714,7 +611,7 @@ declare class ErrorX extends Error {
|
|
|
714
611
|
* // Rate limiting example
|
|
715
612
|
* if (isRateLimited(req.ip)) {
|
|
716
613
|
* throw new ErrorX({
|
|
717
|
-
* ...
|
|
614
|
+
* ...http.tooManyRequests,
|
|
718
615
|
* metadata: {
|
|
719
616
|
* ip: req.ip,
|
|
720
617
|
* retryAfter: 60
|
|
@@ -725,325 +622,319 @@ declare class ErrorX extends Error {
|
|
|
725
622
|
*
|
|
726
623
|
* @public
|
|
727
624
|
*/
|
|
728
|
-
declare const
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
code: string;
|
|
1041
|
-
name: string;
|
|
1042
|
-
message: string;
|
|
1043
|
-
uiMessage: string;
|
|
1044
|
-
type: string;
|
|
1045
|
-
};
|
|
625
|
+
declare const http: {
|
|
626
|
+
readonly badRequest: {
|
|
627
|
+
httpStatus: number;
|
|
628
|
+
code: string;
|
|
629
|
+
name: string;
|
|
630
|
+
message: string;
|
|
631
|
+
uiMessage: string;
|
|
632
|
+
type: string;
|
|
633
|
+
};
|
|
634
|
+
readonly unauthorized: {
|
|
635
|
+
httpStatus: number;
|
|
636
|
+
code: string;
|
|
637
|
+
name: string;
|
|
638
|
+
message: string;
|
|
639
|
+
uiMessage: string;
|
|
640
|
+
type: string;
|
|
641
|
+
};
|
|
642
|
+
readonly paymentRequired: {
|
|
643
|
+
httpStatus: number;
|
|
644
|
+
code: string;
|
|
645
|
+
name: string;
|
|
646
|
+
message: string;
|
|
647
|
+
uiMessage: string;
|
|
648
|
+
type: string;
|
|
649
|
+
};
|
|
650
|
+
readonly forbidden: {
|
|
651
|
+
httpStatus: number;
|
|
652
|
+
code: string;
|
|
653
|
+
name: string;
|
|
654
|
+
message: string;
|
|
655
|
+
uiMessage: string;
|
|
656
|
+
type: string;
|
|
657
|
+
};
|
|
658
|
+
readonly notFound: {
|
|
659
|
+
httpStatus: number;
|
|
660
|
+
code: string;
|
|
661
|
+
name: string;
|
|
662
|
+
message: string;
|
|
663
|
+
uiMessage: string;
|
|
664
|
+
type: string;
|
|
665
|
+
};
|
|
666
|
+
readonly methodNotAllowed: {
|
|
667
|
+
httpStatus: number;
|
|
668
|
+
code: string;
|
|
669
|
+
name: string;
|
|
670
|
+
message: string;
|
|
671
|
+
uiMessage: string;
|
|
672
|
+
type: string;
|
|
673
|
+
};
|
|
674
|
+
readonly notAcceptable: {
|
|
675
|
+
httpStatus: number;
|
|
676
|
+
code: string;
|
|
677
|
+
name: string;
|
|
678
|
+
message: string;
|
|
679
|
+
uiMessage: string;
|
|
680
|
+
type: string;
|
|
681
|
+
};
|
|
682
|
+
readonly proxyAuthenticationRequired: {
|
|
683
|
+
httpStatus: number;
|
|
684
|
+
code: string;
|
|
685
|
+
name: string;
|
|
686
|
+
message: string;
|
|
687
|
+
uiMessage: string;
|
|
688
|
+
type: string;
|
|
689
|
+
};
|
|
690
|
+
readonly requestTimeout: {
|
|
691
|
+
httpStatus: number;
|
|
692
|
+
code: string;
|
|
693
|
+
name: string;
|
|
694
|
+
message: string;
|
|
695
|
+
uiMessage: string;
|
|
696
|
+
type: string;
|
|
697
|
+
};
|
|
698
|
+
readonly conflict: {
|
|
699
|
+
httpStatus: number;
|
|
700
|
+
code: string;
|
|
701
|
+
name: string;
|
|
702
|
+
message: string;
|
|
703
|
+
uiMessage: string;
|
|
704
|
+
type: string;
|
|
705
|
+
};
|
|
706
|
+
readonly gone: {
|
|
707
|
+
httpStatus: number;
|
|
708
|
+
code: string;
|
|
709
|
+
name: string;
|
|
710
|
+
message: string;
|
|
711
|
+
uiMessage: string;
|
|
712
|
+
type: string;
|
|
713
|
+
};
|
|
714
|
+
readonly lengthRequired: {
|
|
715
|
+
httpStatus: number;
|
|
716
|
+
code: string;
|
|
717
|
+
name: string;
|
|
718
|
+
message: string;
|
|
719
|
+
uiMessage: string;
|
|
720
|
+
type: string;
|
|
721
|
+
};
|
|
722
|
+
readonly preconditionFailed: {
|
|
723
|
+
httpStatus: number;
|
|
724
|
+
code: string;
|
|
725
|
+
name: string;
|
|
726
|
+
message: string;
|
|
727
|
+
uiMessage: string;
|
|
728
|
+
type: string;
|
|
729
|
+
};
|
|
730
|
+
readonly payloadTooLarge: {
|
|
731
|
+
httpStatus: number;
|
|
732
|
+
code: string;
|
|
733
|
+
name: string;
|
|
734
|
+
message: string;
|
|
735
|
+
uiMessage: string;
|
|
736
|
+
type: string;
|
|
737
|
+
};
|
|
738
|
+
readonly uriTooLong: {
|
|
739
|
+
httpStatus: number;
|
|
740
|
+
code: string;
|
|
741
|
+
name: string;
|
|
742
|
+
message: string;
|
|
743
|
+
uiMessage: string;
|
|
744
|
+
type: string;
|
|
745
|
+
};
|
|
746
|
+
readonly unsupportedMediaType: {
|
|
747
|
+
httpStatus: number;
|
|
748
|
+
code: string;
|
|
749
|
+
name: string;
|
|
750
|
+
message: string;
|
|
751
|
+
uiMessage: string;
|
|
752
|
+
type: string;
|
|
753
|
+
};
|
|
754
|
+
readonly rangeNotSatisfiable: {
|
|
755
|
+
httpStatus: number;
|
|
756
|
+
code: string;
|
|
757
|
+
name: string;
|
|
758
|
+
message: string;
|
|
759
|
+
uiMessage: string;
|
|
760
|
+
type: string;
|
|
761
|
+
};
|
|
762
|
+
readonly expectationFailed: {
|
|
763
|
+
httpStatus: number;
|
|
764
|
+
code: string;
|
|
765
|
+
name: string;
|
|
766
|
+
message: string;
|
|
767
|
+
uiMessage: string;
|
|
768
|
+
type: string;
|
|
769
|
+
};
|
|
770
|
+
readonly imATeapot: {
|
|
771
|
+
httpStatus: number;
|
|
772
|
+
code: string;
|
|
773
|
+
name: string;
|
|
774
|
+
message: string;
|
|
775
|
+
uiMessage: string;
|
|
776
|
+
type: string;
|
|
777
|
+
};
|
|
778
|
+
readonly unprocessableEntity: {
|
|
779
|
+
httpStatus: number;
|
|
780
|
+
code: string;
|
|
781
|
+
name: string;
|
|
782
|
+
message: string;
|
|
783
|
+
uiMessage: string;
|
|
784
|
+
type: string;
|
|
785
|
+
};
|
|
786
|
+
readonly locked: {
|
|
787
|
+
httpStatus: number;
|
|
788
|
+
code: string;
|
|
789
|
+
name: string;
|
|
790
|
+
message: string;
|
|
791
|
+
uiMessage: string;
|
|
792
|
+
type: string;
|
|
793
|
+
};
|
|
794
|
+
readonly failedDependency: {
|
|
795
|
+
httpStatus: number;
|
|
796
|
+
code: string;
|
|
797
|
+
name: string;
|
|
798
|
+
message: string;
|
|
799
|
+
uiMessage: string;
|
|
800
|
+
type: string;
|
|
801
|
+
};
|
|
802
|
+
readonly tooEarly: {
|
|
803
|
+
httpStatus: number;
|
|
804
|
+
code: string;
|
|
805
|
+
name: string;
|
|
806
|
+
message: string;
|
|
807
|
+
uiMessage: string;
|
|
808
|
+
type: string;
|
|
809
|
+
};
|
|
810
|
+
readonly upgradeRequired: {
|
|
811
|
+
httpStatus: number;
|
|
812
|
+
code: string;
|
|
813
|
+
name: string;
|
|
814
|
+
message: string;
|
|
815
|
+
uiMessage: string;
|
|
816
|
+
type: string;
|
|
817
|
+
};
|
|
818
|
+
readonly preconditionRequired: {
|
|
819
|
+
httpStatus: number;
|
|
820
|
+
code: string;
|
|
821
|
+
name: string;
|
|
822
|
+
message: string;
|
|
823
|
+
uiMessage: string;
|
|
824
|
+
type: string;
|
|
825
|
+
};
|
|
826
|
+
readonly tooManyRequests: {
|
|
827
|
+
httpStatus: number;
|
|
828
|
+
code: string;
|
|
829
|
+
name: string;
|
|
830
|
+
message: string;
|
|
831
|
+
uiMessage: string;
|
|
832
|
+
type: string;
|
|
833
|
+
};
|
|
834
|
+
readonly requestHeaderFieldsTooLarge: {
|
|
835
|
+
httpStatus: number;
|
|
836
|
+
code: string;
|
|
837
|
+
name: string;
|
|
838
|
+
message: string;
|
|
839
|
+
uiMessage: string;
|
|
840
|
+
type: string;
|
|
841
|
+
};
|
|
842
|
+
readonly unavailableForLegalReasons: {
|
|
843
|
+
httpStatus: number;
|
|
844
|
+
code: string;
|
|
845
|
+
name: string;
|
|
846
|
+
message: string;
|
|
847
|
+
uiMessage: string;
|
|
848
|
+
type: string;
|
|
849
|
+
};
|
|
850
|
+
readonly internalServerError: {
|
|
851
|
+
httpStatus: number;
|
|
852
|
+
code: string;
|
|
853
|
+
name: string;
|
|
854
|
+
message: string;
|
|
855
|
+
uiMessage: string;
|
|
856
|
+
type: string;
|
|
857
|
+
};
|
|
858
|
+
readonly notImplemented: {
|
|
859
|
+
httpStatus: number;
|
|
860
|
+
code: string;
|
|
861
|
+
name: string;
|
|
862
|
+
message: string;
|
|
863
|
+
uiMessage: string;
|
|
864
|
+
type: string;
|
|
865
|
+
};
|
|
866
|
+
readonly badGateway: {
|
|
867
|
+
httpStatus: number;
|
|
868
|
+
code: string;
|
|
869
|
+
name: string;
|
|
870
|
+
message: string;
|
|
871
|
+
uiMessage: string;
|
|
872
|
+
type: string;
|
|
873
|
+
};
|
|
874
|
+
readonly serviceUnavailable: {
|
|
875
|
+
httpStatus: number;
|
|
876
|
+
code: string;
|
|
877
|
+
name: string;
|
|
878
|
+
message: string;
|
|
879
|
+
uiMessage: string;
|
|
880
|
+
type: string;
|
|
881
|
+
};
|
|
882
|
+
readonly gatewayTimeout: {
|
|
883
|
+
httpStatus: number;
|
|
884
|
+
code: string;
|
|
885
|
+
name: string;
|
|
886
|
+
message: string;
|
|
887
|
+
uiMessage: string;
|
|
888
|
+
type: string;
|
|
889
|
+
};
|
|
890
|
+
readonly httpVersionNotSupported: {
|
|
891
|
+
httpStatus: number;
|
|
892
|
+
code: string;
|
|
893
|
+
name: string;
|
|
894
|
+
message: string;
|
|
895
|
+
uiMessage: string;
|
|
896
|
+
type: string;
|
|
897
|
+
};
|
|
898
|
+
readonly variantAlsoNegotiates: {
|
|
899
|
+
httpStatus: number;
|
|
900
|
+
code: string;
|
|
901
|
+
name: string;
|
|
902
|
+
message: string;
|
|
903
|
+
uiMessage: string;
|
|
904
|
+
type: string;
|
|
905
|
+
};
|
|
906
|
+
readonly insufficientStorage: {
|
|
907
|
+
httpStatus: number;
|
|
908
|
+
code: string;
|
|
909
|
+
name: string;
|
|
910
|
+
message: string;
|
|
911
|
+
uiMessage: string;
|
|
912
|
+
type: string;
|
|
913
|
+
};
|
|
914
|
+
readonly loopDetected: {
|
|
915
|
+
httpStatus: number;
|
|
916
|
+
code: string;
|
|
917
|
+
name: string;
|
|
918
|
+
message: string;
|
|
919
|
+
uiMessage: string;
|
|
920
|
+
type: string;
|
|
921
|
+
};
|
|
922
|
+
readonly notExtended: {
|
|
923
|
+
httpStatus: number;
|
|
924
|
+
code: string;
|
|
925
|
+
name: string;
|
|
926
|
+
message: string;
|
|
927
|
+
uiMessage: string;
|
|
928
|
+
type: string;
|
|
929
|
+
};
|
|
930
|
+
readonly networkAuthenticationRequired: {
|
|
931
|
+
httpStatus: number;
|
|
932
|
+
code: string;
|
|
933
|
+
name: string;
|
|
934
|
+
message: string;
|
|
935
|
+
uiMessage: string;
|
|
936
|
+
type: string;
|
|
1046
937
|
};
|
|
1047
938
|
};
|
|
1048
939
|
|
|
1049
|
-
export {
|
|
940
|
+
export { ErrorX, type ErrorXCause, type ErrorXConfig, type ErrorXMetadata, type ErrorXOptions, type ErrorXSerialized, http };
|