error-shield 1.0.0 → 2.0.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 CHANGED
@@ -1,6 +1,6 @@
1
- # error-handler
1
+ # Error Shield
2
2
 
3
- A comprehensive error handling utility for Node.js applications. Provides structured error handling, formatting, and Express.js middleware support.
3
+ A comprehensive error handling utility for Node.js & Express.js applications. Provides structured error handling, formatting, and Express.js middleware support.
4
4
 
5
5
  ## Features
6
6
 
@@ -14,7 +14,7 @@ A comprehensive error handling utility for Node.js applications. Provides struct
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- npm install error-handler
17
+ npm install error-shield
18
18
  ```
19
19
 
20
20
  ## Usage
@@ -22,18 +22,18 @@ npm install error-handler
22
22
  ### Basic Usage
23
23
 
24
24
  ```javascript
25
- const { AppError, handleError, ErrorCreators } = require('error-handler');
25
+ const { AppError, handleError, ErrorCreators } = require("error-shield");
26
26
 
27
27
  // Create a custom error
28
- const error = new AppError('Something went wrong', 500, 'CUSTOM_ERROR', {
28
+ const error = new AppError("Something went wrong", 500, "CUSTOM_ERROR", {
29
29
  userId: 123,
30
- action: 'updateProfile'
30
+ action: "updateProfile",
31
31
  });
32
32
 
33
33
  // Handle and format error
34
34
  const errorDetails = handleError(error, {
35
35
  includeStack: true,
36
- includeTimestamp: true
36
+ includeTimestamp: true,
37
37
  });
38
38
 
39
39
  console.log(errorDetails);
@@ -42,43 +42,45 @@ console.log(errorDetails);
42
42
  ### Using Error Creators
43
43
 
44
44
  ```javascript
45
- const { ErrorCreators } = require('error-handler');
45
+ const { ErrorCreators } = require("error-shield");
46
46
 
47
47
  // Bad Request (400)
48
- throw ErrorCreators.badRequest('Invalid input provided', { field: 'email' });
48
+ throw ErrorCreators.badRequest("Invalid input provided", { field: "email" });
49
49
 
50
50
  // Unauthorized (401)
51
- throw ErrorCreators.unauthorized('Authentication required');
51
+ throw ErrorCreators.unauthorized("Authentication required");
52
52
 
53
53
  // Not Found (404)
54
- throw ErrorCreators.notFound('User not found', { userId: 123 });
54
+ throw ErrorCreators.notFound("User not found", { userId: 123 });
55
55
 
56
56
  // Validation Error (422)
57
- throw ErrorCreators.validationError('Email is required', { field: 'email' });
57
+ throw ErrorCreators.validationError("Email is required", { field: "email" });
58
58
  ```
59
59
 
60
60
  ### Express.js Middleware
61
61
 
62
62
  ```javascript
63
- const express = require('express');
64
- const { expressErrorHandler, ErrorCreators } = require('error-handler');
63
+ const express = require("express");
64
+ const { expressErrorHandler, ErrorCreators } = require("error-shield");
65
65
 
66
66
  const app = express();
67
67
 
68
68
  // Your routes
69
- app.get('/users/:id', async (req, res, next) => {
69
+ app.get("/users/:id", async (req, res, next) => {
70
70
  const user = await getUserById(req.params.id);
71
71
  if (!user) {
72
- throw ErrorCreators.notFound('User not found', { userId: req.params.id });
72
+ throw ErrorCreators.notFound("User not found", { userId: req.params.id });
73
73
  }
74
74
  res.json(user);
75
75
  });
76
76
 
77
77
  // Error handler middleware (must be last)
78
- app.use(expressErrorHandler({
79
- includeStack: process.env.NODE_ENV !== 'production',
80
- includeTimestamp: true
81
- }));
78
+ app.use(
79
+ expressErrorHandler({
80
+ includeStack: process.env.NODE_ENV !== "production",
81
+ includeTimestamp: true,
82
+ }),
83
+ );
82
84
 
83
85
  app.listen(3000);
84
86
  ```
@@ -86,26 +88,29 @@ app.listen(3000);
86
88
  ### Async Handler Wrapper
87
89
 
88
90
  ```javascript
89
- const { asyncHandler } = require('error-handler');
91
+ const { asyncHandler } = require("error-shield");
90
92
 
91
93
  // Wrap async route handlers
92
- app.get('/api/data', asyncHandler(async (req, res) => {
93
- const data = await fetchData();
94
- res.json(data);
95
- }));
94
+ app.get(
95
+ "/api/data",
96
+ asyncHandler(async (req, res) => {
97
+ const data = await fetchData();
98
+ res.json(data);
99
+ }),
100
+ );
96
101
  ```
97
102
 
98
103
  ### Custom Logger
99
104
 
100
105
  ```javascript
101
- const { handleError } = require('error-handler');
106
+ const { handleError } = require("error-shield");
102
107
 
103
108
  const errorDetails = handleError(error, {
104
109
  logger: (errorDetails) => {
105
110
  // Custom logging logic
106
- console.error('Error occurred:', errorDetails);
111
+ console.error("Error occurred:", errorDetails);
107
112
  // Send to logging service, etc.
108
- }
113
+ },
109
114
  });
110
115
  ```
111
116
 
@@ -125,6 +130,7 @@ class AppError extends Error {
125
130
  ```
126
131
 
127
132
  **Constructor:**
133
+
128
134
  - `message: string` - Error message
129
135
  - `statusCode: number` - HTTP status code (default: 500)
130
136
  - `code?: string` - Error code
@@ -135,6 +141,7 @@ class AppError extends Error {
135
141
  Formats an error into a structured object.
136
142
 
137
143
  **Parameters:**
144
+
138
145
  - `error: Error | AppError` - The error to format
139
146
  - `options: ErrorHandlerOptions` - Formatting options
140
147
 
@@ -145,6 +152,7 @@ Formats an error into a structured object.
145
152
  Handles errors with optional logging and formatting.
146
153
 
147
154
  **Parameters:**
155
+
148
156
  - `error: Error | AppError` - The error to handle
149
157
  - `options: ErrorHandlerOptions` - Handler options
150
158
 
@@ -155,6 +163,7 @@ Handles errors with optional logging and formatting.
155
163
  Wraps an async function to catch errors.
156
164
 
157
165
  **Parameters:**
166
+
158
167
  - `fn: Function` - Async function to wrap
159
168
 
160
169
  **Returns:** Wrapped function
@@ -164,31 +173,76 @@ Wraps an async function to catch errors.
164
173
  Creates an Express.js error handler middleware.
165
174
 
166
175
  **Parameters:**
176
+
167
177
  - `options: ErrorHandlerOptions` - Handler options
168
178
 
169
179
  **Returns:** Express middleware function
170
180
 
171
181
  ### `ErrorCreators`
172
182
 
173
- Pre-built error creators for common HTTP status codes:
174
-
175
- - `badRequest(message, context?)` - 400
176
- - `unauthorized(message?, context?)` - 401
177
- - `forbidden(message?, context?)` - 403
178
- - `notFound(message?, context?)` - 404
179
- - `conflict(message, context?)` - 409
180
- - `validationError(message, context?)` - 422
181
- - `internalServerError(message?, context?)` - 500
182
- - `serviceUnavailable(message?, context?)` - 503
183
+ Pre-built error creators for all standard HTTP error status codes:
184
+
185
+ **4xx Client Errors:**
186
+
187
+ | Method | Code | Default Message |
188
+ | ------------------------------------------------- | ---- | ------------------------------- |
189
+ | `badRequest(message, context?)` | 400 | _(required)_ |
190
+ | `unauthorized(message?, context?)` | 401 | Unauthorized |
191
+ | `paymentRequired(message?, context?)` | 402 | Payment Required |
192
+ | `forbidden(message?, context?)` | 403 | Forbidden |
193
+ | `notFound(message?, context?)` | 404 | Not Found |
194
+ | `methodNotAllowed(message?, context?)` | 405 | Method Not Allowed |
195
+ | `notAcceptable(message?, context?)` | 406 | Not Acceptable |
196
+ | `proxyAuthRequired(message?, context?)` | 407 | Proxy Authentication Required |
197
+ | `requestTimeout(message?, context?)` | 408 | Request Timeout |
198
+ | `conflict(message, context?)` | 409 | _(required)_ |
199
+ | `gone(message?, context?)` | 410 | Gone |
200
+ | `lengthRequired(message?, context?)` | 411 | Length Required |
201
+ | `preconditionFailed(message?, context?)` | 412 | Precondition Failed |
202
+ | `payloadTooLarge(message?, context?)` | 413 | Payload Too Large |
203
+ | `uriTooLong(message?, context?)` | 414 | URI Too Long |
204
+ | `unsupportedMediaType(message?, context?)` | 415 | Unsupported Media Type |
205
+ | `rangeNotSatisfiable(message?, context?)` | 416 | Range Not Satisfiable |
206
+ | `expectationFailed(message?, context?)` | 417 | Expectation Failed |
207
+ | `imATeapot(message?, context?)` | 418 | I'm a Teapot |
208
+ | `misdirectedRequest(message?, context?)` | 421 | Misdirected Request |
209
+ | `unprocessableEntity(message?, context?)` | 422 | Unprocessable Entity |
210
+ | `validationError(message, context?)` | 422 | _(required)_ |
211
+ | `locked(message?, context?)` | 423 | Locked |
212
+ | `failedDependency(message?, context?)` | 424 | Failed Dependency |
213
+ | `tooEarly(message?, context?)` | 425 | Too Early |
214
+ | `upgradeRequired(message?, context?)` | 426 | Upgrade Required |
215
+ | `preconditionRequired(message?, context?)` | 428 | Precondition Required |
216
+ | `tooManyRequests(message?, context?)` | 429 | Too Many Requests |
217
+ | `requestHeaderFieldsTooLarge(message?, context?)` | 431 | Request Header Fields Too Large |
218
+ | `unavailableForLegalReasons(message?, context?)` | 451 | Unavailable For Legal Reasons |
219
+
220
+ **5xx Server Errors:**
221
+
222
+ | Method | Code | Default Message |
223
+ | --------------------------------------------------- | ---- | ------------------------------- |
224
+ | `internalServerError(message?, context?)` | 500 | Internal Server Error |
225
+ | `notImplemented(message?, context?)` | 501 | Not Implemented |
226
+ | `badGateway(message?, context?)` | 502 | Bad Gateway |
227
+ | `serviceUnavailable(message?, context?)` | 503 | Service Unavailable |
228
+ | `gatewayTimeout(message?, context?)` | 504 | Gateway Timeout |
229
+ | `httpVersionNotSupported(message?, context?)` | 505 | HTTP Version Not Supported |
230
+ | `variantAlsoNegotiates(message?, context?)` | 506 | Variant Also Negotiates |
231
+ | `insufficientStorage(message?, context?)` | 507 | Insufficient Storage |
232
+ | `loopDetected(message?, context?)` | 508 | Loop Detected |
233
+ | `bandwidthLimitExceeded(message?, context?)` | 509 | Bandwidth Limit Exceeded |
234
+ | `notExtended(message?, context?)` | 510 | Not Extended |
235
+ | `networkAuthenticationRequired(message?, context?)` | 511 | Network Authentication Required |
236
+ | `networkConnectTimeout(message?, context?)` | 599 | Network Connect Timeout |
183
237
 
184
238
  ## TypeScript Support
185
239
 
186
240
  This package includes full TypeScript definitions:
187
241
 
188
242
  ```typescript
189
- import { AppError, ErrorCreators, handleError } from 'error-handler';
243
+ import { AppError, ErrorCreators, handleError } from "error-shield";
190
244
 
191
- const error: AppError = ErrorCreators.notFound('User not found');
245
+ const error: AppError = ErrorCreators.notFound("User not found");
192
246
  const details = handleError(error);
193
247
  ```
194
248
 
package/dist/index.d.ts CHANGED
@@ -54,12 +54,47 @@ export declare function createErrorResponse(message: string, statusCode?: number
54
54
  export declare const ErrorCreators: {
55
55
  badRequest: (message: string, context?: Record<string, any>) => AppError;
56
56
  unauthorized: (message?: string, context?: Record<string, any>) => AppError;
57
+ paymentRequired: (message?: string, context?: Record<string, any>) => AppError;
57
58
  forbidden: (message?: string, context?: Record<string, any>) => AppError;
58
59
  notFound: (message?: string, context?: Record<string, any>) => AppError;
60
+ methodNotAllowed: (message?: string, context?: Record<string, any>) => AppError;
61
+ notAcceptable: (message?: string, context?: Record<string, any>) => AppError;
62
+ proxyAuthRequired: (message?: string, context?: Record<string, any>) => AppError;
63
+ requestTimeout: (message?: string, context?: Record<string, any>) => AppError;
59
64
  conflict: (message: string, context?: Record<string, any>) => AppError;
65
+ gone: (message?: string, context?: Record<string, any>) => AppError;
66
+ lengthRequired: (message?: string, context?: Record<string, any>) => AppError;
67
+ preconditionFailed: (message?: string, context?: Record<string, any>) => AppError;
68
+ payloadTooLarge: (message?: string, context?: Record<string, any>) => AppError;
69
+ uriTooLong: (message?: string, context?: Record<string, any>) => AppError;
70
+ unsupportedMediaType: (message?: string, context?: Record<string, any>) => AppError;
71
+ rangeNotSatisfiable: (message?: string, context?: Record<string, any>) => AppError;
72
+ expectationFailed: (message?: string, context?: Record<string, any>) => AppError;
73
+ imATeapot: (message?: string, context?: Record<string, any>) => AppError;
74
+ misdirectedRequest: (message?: string, context?: Record<string, any>) => AppError;
75
+ unprocessableEntity: (message?: string, context?: Record<string, any>) => AppError;
60
76
  validationError: (message: string, context?: Record<string, any>) => AppError;
77
+ locked: (message?: string, context?: Record<string, any>) => AppError;
78
+ failedDependency: (message?: string, context?: Record<string, any>) => AppError;
79
+ tooEarly: (message?: string, context?: Record<string, any>) => AppError;
80
+ upgradeRequired: (message?: string, context?: Record<string, any>) => AppError;
81
+ preconditionRequired: (message?: string, context?: Record<string, any>) => AppError;
82
+ tooManyRequests: (message?: string, context?: Record<string, any>) => AppError;
83
+ requestHeaderFieldsTooLarge: (message?: string, context?: Record<string, any>) => AppError;
84
+ unavailableForLegalReasons: (message?: string, context?: Record<string, any>) => AppError;
61
85
  internalServerError: (message?: string, context?: Record<string, any>) => AppError;
86
+ notImplemented: (message?: string, context?: Record<string, any>) => AppError;
87
+ badGateway: (message?: string, context?: Record<string, any>) => AppError;
62
88
  serviceUnavailable: (message?: string, context?: Record<string, any>) => AppError;
89
+ gatewayTimeout: (message?: string, context?: Record<string, any>) => AppError;
90
+ httpVersionNotSupported: (message?: string, context?: Record<string, any>) => AppError;
91
+ variantAlsoNegotiates: (message?: string, context?: Record<string, any>) => AppError;
92
+ insufficientStorage: (message?: string, context?: Record<string, any>) => AppError;
93
+ loopDetected: (message?: string, context?: Record<string, any>) => AppError;
94
+ bandwidthLimitExceeded: (message?: string, context?: Record<string, any>) => AppError;
95
+ notExtended: (message?: string, context?: Record<string, any>) => AppError;
96
+ networkAuthenticationRequired: (message?: string, context?: Record<string, any>) => AppError;
97
+ networkConnectTimeout: (message?: string, context?: Record<string, any>) => AppError;
63
98
  };
64
99
  declare const _default: {
65
100
  AppError: typeof AppError;
@@ -71,12 +106,47 @@ declare const _default: {
71
106
  ErrorCreators: {
72
107
  badRequest: (message: string, context?: Record<string, any>) => AppError;
73
108
  unauthorized: (message?: string, context?: Record<string, any>) => AppError;
109
+ paymentRequired: (message?: string, context?: Record<string, any>) => AppError;
74
110
  forbidden: (message?: string, context?: Record<string, any>) => AppError;
75
111
  notFound: (message?: string, context?: Record<string, any>) => AppError;
112
+ methodNotAllowed: (message?: string, context?: Record<string, any>) => AppError;
113
+ notAcceptable: (message?: string, context?: Record<string, any>) => AppError;
114
+ proxyAuthRequired: (message?: string, context?: Record<string, any>) => AppError;
115
+ requestTimeout: (message?: string, context?: Record<string, any>) => AppError;
76
116
  conflict: (message: string, context?: Record<string, any>) => AppError;
117
+ gone: (message?: string, context?: Record<string, any>) => AppError;
118
+ lengthRequired: (message?: string, context?: Record<string, any>) => AppError;
119
+ preconditionFailed: (message?: string, context?: Record<string, any>) => AppError;
120
+ payloadTooLarge: (message?: string, context?: Record<string, any>) => AppError;
121
+ uriTooLong: (message?: string, context?: Record<string, any>) => AppError;
122
+ unsupportedMediaType: (message?: string, context?: Record<string, any>) => AppError;
123
+ rangeNotSatisfiable: (message?: string, context?: Record<string, any>) => AppError;
124
+ expectationFailed: (message?: string, context?: Record<string, any>) => AppError;
125
+ imATeapot: (message?: string, context?: Record<string, any>) => AppError;
126
+ misdirectedRequest: (message?: string, context?: Record<string, any>) => AppError;
127
+ unprocessableEntity: (message?: string, context?: Record<string, any>) => AppError;
77
128
  validationError: (message: string, context?: Record<string, any>) => AppError;
129
+ locked: (message?: string, context?: Record<string, any>) => AppError;
130
+ failedDependency: (message?: string, context?: Record<string, any>) => AppError;
131
+ tooEarly: (message?: string, context?: Record<string, any>) => AppError;
132
+ upgradeRequired: (message?: string, context?: Record<string, any>) => AppError;
133
+ preconditionRequired: (message?: string, context?: Record<string, any>) => AppError;
134
+ tooManyRequests: (message?: string, context?: Record<string, any>) => AppError;
135
+ requestHeaderFieldsTooLarge: (message?: string, context?: Record<string, any>) => AppError;
136
+ unavailableForLegalReasons: (message?: string, context?: Record<string, any>) => AppError;
78
137
  internalServerError: (message?: string, context?: Record<string, any>) => AppError;
138
+ notImplemented: (message?: string, context?: Record<string, any>) => AppError;
139
+ badGateway: (message?: string, context?: Record<string, any>) => AppError;
79
140
  serviceUnavailable: (message?: string, context?: Record<string, any>) => AppError;
141
+ gatewayTimeout: (message?: string, context?: Record<string, any>) => AppError;
142
+ httpVersionNotSupported: (message?: string, context?: Record<string, any>) => AppError;
143
+ variantAlsoNegotiates: (message?: string, context?: Record<string, any>) => AppError;
144
+ insufficientStorage: (message?: string, context?: Record<string, any>) => AppError;
145
+ loopDetected: (message?: string, context?: Record<string, any>) => AppError;
146
+ bandwidthLimitExceeded: (message?: string, context?: Record<string, any>) => AppError;
147
+ notExtended: (message?: string, context?: Record<string, any>) => AppError;
148
+ networkAuthenticationRequired: (message?: string, context?: Record<string, any>) => AppError;
149
+ networkConnectTimeout: (message?: string, context?: Record<string, any>) => AppError;
80
150
  };
81
151
  };
82
152
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,YAAY;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,CAAC;wCAI9E,MAAM,YAAsC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;mCAGpE,MAAM,YAAgC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;+BAG7D,MAAM,YAA4B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;uCAG7C,MAAM,YAAoC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;mCAGjE,MAAM,YAAgC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;4CAGhD,MAAM,YAA2C,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;0CAGtE,MAAM,YAAwC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;wCAGnE,MAAM,YAAqC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;iCAGrE,MAAM,YAA8B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;2CAG7C,MAAM,YAAyC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;gCAG7E,MAAM,YAA6B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;kDAGpC,MAAM,YAAgD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;0CAGjF,MAAM,YAAwC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;AAKpG,wBAQE"}
package/dist/index.js CHANGED
@@ -101,14 +101,51 @@ function createErrorResponse(message, statusCode = 500, code, context) {
101
101
  * Common error creators
102
102
  */
103
103
  exports.ErrorCreators = {
104
+ // 4xx Client Errors
104
105
  badRequest: (message, context) => new AppError(message, 400, 'BAD_REQUEST', context),
105
106
  unauthorized: (message = 'Unauthorized', context) => new AppError(message, 401, 'UNAUTHORIZED', context),
107
+ paymentRequired: (message = 'Payment Required', context) => new AppError(message, 402, 'PAYMENT_REQUIRED', context),
106
108
  forbidden: (message = 'Forbidden', context) => new AppError(message, 403, 'FORBIDDEN', context),
107
109
  notFound: (message = 'Not Found', context) => new AppError(message, 404, 'NOT_FOUND', context),
110
+ methodNotAllowed: (message = 'Method Not Allowed', context) => new AppError(message, 405, 'METHOD_NOT_ALLOWED', context),
111
+ notAcceptable: (message = 'Not Acceptable', context) => new AppError(message, 406, 'NOT_ACCEPTABLE', context),
112
+ proxyAuthRequired: (message = 'Proxy Authentication Required', context) => new AppError(message, 407, 'PROXY_AUTH_REQUIRED', context),
113
+ requestTimeout: (message = 'Request Timeout', context) => new AppError(message, 408, 'REQUEST_TIMEOUT', context),
108
114
  conflict: (message, context) => new AppError(message, 409, 'CONFLICT', context),
115
+ gone: (message = 'Gone', context) => new AppError(message, 410, 'GONE', context),
116
+ lengthRequired: (message = 'Length Required', context) => new AppError(message, 411, 'LENGTH_REQUIRED', context),
117
+ preconditionFailed: (message = 'Precondition Failed', context) => new AppError(message, 412, 'PRECONDITION_FAILED', context),
118
+ payloadTooLarge: (message = 'Payload Too Large', context) => new AppError(message, 413, 'PAYLOAD_TOO_LARGE', context),
119
+ uriTooLong: (message = 'URI Too Long', context) => new AppError(message, 414, 'URI_TOO_LONG', context),
120
+ unsupportedMediaType: (message = 'Unsupported Media Type', context) => new AppError(message, 415, 'UNSUPPORTED_MEDIA_TYPE', context),
121
+ rangeNotSatisfiable: (message = 'Range Not Satisfiable', context) => new AppError(message, 416, 'RANGE_NOT_SATISFIABLE', context),
122
+ expectationFailed: (message = 'Expectation Failed', context) => new AppError(message, 417, 'EXPECTATION_FAILED', context),
123
+ imATeapot: (message = "I'm a Teapot", context) => new AppError(message, 418, 'IM_A_TEAPOT', context),
124
+ misdirectedRequest: (message = 'Misdirected Request', context) => new AppError(message, 421, 'MISDIRECTED_REQUEST', context),
125
+ unprocessableEntity: (message = 'Unprocessable Entity', context) => new AppError(message, 422, 'UNPROCESSABLE_ENTITY', context),
109
126
  validationError: (message, context) => new AppError(message, 422, 'VALIDATION_ERROR', context),
127
+ locked: (message = 'Locked', context) => new AppError(message, 423, 'LOCKED', context),
128
+ failedDependency: (message = 'Failed Dependency', context) => new AppError(message, 424, 'FAILED_DEPENDENCY', context),
129
+ tooEarly: (message = 'Too Early', context) => new AppError(message, 425, 'TOO_EARLY', context),
130
+ upgradeRequired: (message = 'Upgrade Required', context) => new AppError(message, 426, 'UPGRADE_REQUIRED', context),
131
+ preconditionRequired: (message = 'Precondition Required', context) => new AppError(message, 428, 'PRECONDITION_REQUIRED', context),
132
+ tooManyRequests: (message = 'Too Many Requests', context) => new AppError(message, 429, 'TOO_MANY_REQUESTS', context),
133
+ requestHeaderFieldsTooLarge: (message = 'Request Header Fields Too Large', context) => new AppError(message, 431, 'REQUEST_HEADER_FIELDS_TOO_LARGE', context),
134
+ unavailableForLegalReasons: (message = 'Unavailable For Legal Reasons', context) => new AppError(message, 451, 'UNAVAILABLE_FOR_LEGAL_REASONS', context),
135
+ // 5xx Server Errors
110
136
  internalServerError: (message = 'Internal Server Error', context) => new AppError(message, 500, 'INTERNAL_SERVER_ERROR', context),
137
+ notImplemented: (message = 'Not Implemented', context) => new AppError(message, 501, 'NOT_IMPLEMENTED', context),
138
+ badGateway: (message = 'Bad Gateway', context) => new AppError(message, 502, 'BAD_GATEWAY', context),
111
139
  serviceUnavailable: (message = 'Service Unavailable', context) => new AppError(message, 503, 'SERVICE_UNAVAILABLE', context),
140
+ gatewayTimeout: (message = 'Gateway Timeout', context) => new AppError(message, 504, 'GATEWAY_TIMEOUT', context),
141
+ httpVersionNotSupported: (message = 'HTTP Version Not Supported', context) => new AppError(message, 505, 'HTTP_VERSION_NOT_SUPPORTED', context),
142
+ variantAlsoNegotiates: (message = 'Variant Also Negotiates', context) => new AppError(message, 506, 'VARIANT_ALSO_NEGOTIATES', context),
143
+ insufficientStorage: (message = 'Insufficient Storage', context) => new AppError(message, 507, 'INSUFFICIENT_STORAGE', context),
144
+ loopDetected: (message = 'Loop Detected', context) => new AppError(message, 508, 'LOOP_DETECTED', context),
145
+ bandwidthLimitExceeded: (message = 'Bandwidth Limit Exceeded', context) => new AppError(message, 509, 'BANDWIDTH_LIMIT_EXCEEDED', context),
146
+ notExtended: (message = 'Not Extended', context) => new AppError(message, 510, 'NOT_EXTENDED', context),
147
+ networkAuthenticationRequired: (message = 'Network Authentication Required', context) => new AppError(message, 511, 'NETWORK_AUTHENTICATION_REQUIRED', context),
148
+ networkConnectTimeout: (message = 'Network Connect Timeout', context) => new AppError(message, 599, 'NETWORK_CONNECT_TIMEOUT', context),
112
149
  };
113
150
  // Default export
114
151
  exports.default = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAiDH,kCA0BC;AAKD,kCAWC;AAKD,oCAQC;AAKD,kDA4BC;AAKD,kDAOC;AAlID;;GAEG;AACH,MAAa,QAAS,SAAQ,KAAK;IAMjC,YACE,OAAe,EACf,aAAqB,GAAG,EACxB,IAAa,EACb,OAA6B;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAK,KAAa,CAAC,iBAAiB,EAAE,CAAC;YACpC,KAAa,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF;AAtBD,4BAsBC;AAED;;GAEG;AACH,SAAgB,WAAW,CACzB,KAAuB,EACvB,UAA+B,EAAE;IAEjC,MAAM,EACJ,YAAY,GAAG,KAAK,EACpB,gBAAgB,GAAG,IAAI,EACvB,OAAO,EAAE,cAAc,GAAG,EAAE,GAC7B,GAAG,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG,KAAK,YAAY,QAAQ;QAC7C,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,GA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C,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,CAAC;IAErD,6BAA6B,EAAE,CAAC,UAAkB,iCAAiC,EAAE,OAA6B,EAAE,EAAE,CACpH,IAAI,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,iCAAiC,EAAE,OAAO,CAAC;IAExE,qBAAqB,EAAE,CAAC,UAAkB,yBAAyB,EAAE,OAA6B,EAAE,EAAE,CACpG,IAAI,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,yBAAyB,EAAE,OAAO,CAAC;CACjE,CAAC;AAEF,iBAAiB;AACjB,kBAAe;IACb,QAAQ;IACR,WAAW;IACX,WAAW;IACX,YAAY;IACZ,mBAAmB;IACnB,mBAAmB;IACnB,aAAa,EAAb,qBAAa;CACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "error-shield",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "A comprehensive error handling utility for Node.js applications with Express.js middleware support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,14 +15,17 @@
15
15
  },
16
16
  "keywords": [
17
17
  "error",
18
- "error-handler",
18
+ "error-shield",
19
19
  "error-handling",
20
20
  "express",
21
21
  "middleware",
22
22
  "typescript",
23
23
  "nodejs",
24
24
  "exception",
25
- "error-management"
25
+ "error-management",
26
+ "error-handler",
27
+ "custom-error",
28
+ "error-utility"
26
29
  ],
27
30
  "author": "Gopinath Kathirvel",
28
31
  "license": "ISC",