@naman_deep_singh/errors 2.2.3 → 2.3.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/README.md +1 -1
- package/dist/cjs/constants/index.js +5 -16
- package/dist/cjs/error/AppError.js +2 -2
- package/dist/cjs/error/index.js +29 -28
- package/dist/cjs/errorRegistry/errorRegistry.js +3 -1
- package/dist/cjs/errorRegistry/index.js +4 -4
- package/dist/cjs/middleware/express/index.js +5 -16
- package/dist/cjs/middleware/index.js +4 -15
- package/dist/esm/constants/index.js +2 -2
- package/dist/esm/error/AppError.js +1 -1
- package/dist/esm/error/index.js +14 -14
- package/dist/esm/errorRegistry/errorRegistry.js +2 -0
- package/dist/esm/errorRegistry/index.js +1 -3
- package/dist/esm/middleware/express/index.js +2 -2
- package/dist/esm/middleware/index.js +1 -1
- package/dist/types/constants/index.d.ts +2 -2
- package/dist/types/error/index.d.ts +14 -14
- package/dist/types/errorRegistry/errorRegistry.d.ts +2 -0
- package/dist/types/errorRegistry/index.d.ts +1 -3
- package/dist/types/middleware/express/index.d.ts +2 -2
- package/dist/types/middleware/index.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.ERROR_MESSAGES = exports.ERROR_CODES = void 0;
|
|
4
|
+
var errorCodes_js_1 = require("./errorCodes.js");
|
|
5
|
+
Object.defineProperty(exports, "ERROR_CODES", { enumerable: true, get: function () { return errorCodes_js_1.ERROR_CODES; } });
|
|
6
|
+
var errorMessages_js_1 = require("./errorMessages.js");
|
|
7
|
+
Object.defineProperty(exports, "ERROR_MESSAGES", { enumerable: true, get: function () { return errorMessages_js_1.ERROR_MESSAGES; } });
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppError = void 0;
|
|
4
4
|
const http_response_1 = require("@naman_deep_singh/http-response");
|
|
5
|
-
const
|
|
5
|
+
const errorRegistry_js_1 = require("../errorRegistry/errorRegistry.js");
|
|
6
6
|
class AppError extends Error {
|
|
7
7
|
constructor(code, statusCode = http_response_1.HTTP_STATUS.SERVER_ERROR.INTERNAL_SERVER_ERROR, details, cause) {
|
|
8
|
-
super(
|
|
8
|
+
super(errorRegistry_js_1.errorMessageRegistry.resolve(code)); // message comes from mapping
|
|
9
9
|
this.code = code;
|
|
10
10
|
this.statusCode = statusCode;
|
|
11
11
|
this.isOperational = true;
|
package/dist/cjs/error/index.js
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.ServiceUnavailableError = exports.CryptoIntegrityError = exports.InternalServerError = exports.TokenMalformedError = exports.TokenExpiredError = exports.TooManyRequestsError = exports.ValidationError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.HTTPError = exports.AppError = void 0;
|
|
4
|
+
var AppError_js_1 = require("./AppError.js");
|
|
5
|
+
Object.defineProperty(exports, "AppError", { enumerable: true, get: function () { return AppError_js_1.AppError; } });
|
|
6
|
+
var HTTPError_js_1 = require("./HTTPError.js");
|
|
7
|
+
Object.defineProperty(exports, "HTTPError", { enumerable: true, get: function () { return HTTPError_js_1.HTTPError; } });
|
|
19
8
|
// =========================
|
|
20
9
|
// 4xx Client Errors
|
|
21
10
|
// =========================
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
var BadRequestError_js_1 = require("./BadRequestError.js");
|
|
12
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return BadRequestError_js_1.BadRequestError; } });
|
|
13
|
+
var UnauthorizedError_js_1 = require("./UnauthorizedError.js");
|
|
14
|
+
Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return UnauthorizedError_js_1.UnauthorizedError; } });
|
|
15
|
+
var ForbiddenError_js_1 = require("./ForbiddenError.js");
|
|
16
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return ForbiddenError_js_1.ForbiddenError; } });
|
|
17
|
+
var NotFoundError_js_1 = require("./NotFoundError.js");
|
|
18
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return NotFoundError_js_1.NotFoundError; } });
|
|
19
|
+
var ConflictError_js_1 = require("./ConflictError.js");
|
|
20
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return ConflictError_js_1.ConflictError; } });
|
|
21
|
+
var ValidationError_js_1 = require("./ValidationError.js");
|
|
22
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return ValidationError_js_1.ValidationError; } });
|
|
23
|
+
var TooManyRequestsError_js_1 = require("./TooManyRequestsError.js");
|
|
24
|
+
Object.defineProperty(exports, "TooManyRequestsError", { enumerable: true, get: function () { return TooManyRequestsError_js_1.TooManyRequestsError; } });
|
|
29
25
|
// =========================
|
|
30
26
|
// Auth / Token Errors
|
|
31
27
|
// =========================
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
var TokenExpiredError_js_1 = require("./TokenExpiredError.js");
|
|
29
|
+
Object.defineProperty(exports, "TokenExpiredError", { enumerable: true, get: function () { return TokenExpiredError_js_1.TokenExpiredError; } });
|
|
30
|
+
var TokenMalformedError_js_1 = require("./TokenMalformedError.js");
|
|
31
|
+
Object.defineProperty(exports, "TokenMalformedError", { enumerable: true, get: function () { return TokenMalformedError_js_1.TokenMalformedError; } });
|
|
34
32
|
// =========================
|
|
35
33
|
// 5xx Server Errors
|
|
36
34
|
// =========================
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
var InternalServerError_js_1 = require("./InternalServerError.js");
|
|
36
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return InternalServerError_js_1.InternalServerError; } });
|
|
37
|
+
var CryptoIntegrityError_js_1 = require("./CryptoIntegrityError.js");
|
|
38
|
+
Object.defineProperty(exports, "CryptoIntegrityError", { enumerable: true, get: function () { return CryptoIntegrityError_js_1.CryptoIntegrityError; } });
|
|
39
|
+
var ServiceUnavailableError_js_1 = require("./ServiceUnavailableError.js");
|
|
40
|
+
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return ServiceUnavailableError_js_1.ServiceUnavailableError; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorMessageRegistry = void 0;
|
|
3
|
+
exports.errorMessageRegistry = exports.ErrorMessageRegistry = void 0;
|
|
4
4
|
const http_response_1 = require("@naman_deep_singh/http-response");
|
|
5
5
|
const errorMessages_js_1 = require("../constants/errorMessages.js");
|
|
6
6
|
class ErrorMessageRegistry {
|
|
@@ -61,3 +61,5 @@ class ErrorMessageRegistry {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
exports.ErrorMessageRegistry = ErrorMessageRegistry;
|
|
64
|
+
/** Singleton export for easy access */
|
|
65
|
+
exports.errorMessageRegistry = ErrorMessageRegistry.getInstance();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorMessageRegistry = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports
|
|
3
|
+
exports.errorMessageRegistry = exports.ErrorMessageRegistry = void 0;
|
|
4
|
+
var errorRegistry_js_1 = require("./errorRegistry.js");
|
|
5
|
+
Object.defineProperty(exports, "ErrorMessageRegistry", { enumerable: true, get: function () { return errorRegistry_js_1.ErrorMessageRegistry; } });
|
|
6
|
+
Object.defineProperty(exports, "errorMessageRegistry", { enumerable: true, get: function () { return errorRegistry_js_1.errorMessageRegistry; } });
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.errorConverter = exports.expressErrorHandler = void 0;
|
|
4
|
+
var errorHandler_middleware_js_1 = require("./errorHandler.middleware.js");
|
|
5
|
+
Object.defineProperty(exports, "expressErrorHandler", { enumerable: true, get: function () { return errorHandler_middleware_js_1.expressErrorHandler; } });
|
|
6
|
+
var errorConverter_middleware_js_1 = require("./errorConverter.middleware.js");
|
|
7
|
+
Object.defineProperty(exports, "errorConverter", { enumerable: true, get: function () { return errorConverter_middleware_js_1.errorConverter; } });
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
3
|
+
exports.errorConverter = exports.expressErrorHandler = void 0;
|
|
4
|
+
var index_js_1 = require("./express/index.js");
|
|
5
|
+
Object.defineProperty(exports, "expressErrorHandler", { enumerable: true, get: function () { return index_js_1.expressErrorHandler; } });
|
|
6
|
+
Object.defineProperty(exports, "errorConverter", { enumerable: true, get: function () { return index_js_1.errorConverter; } });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { ERROR_CODES } from './errorCodes.js';
|
|
2
|
+
export { ERROR_MESSAGES } from './errorMessages.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTP_STATUS } from '@naman_deep_singh/http-response';
|
|
2
|
-
import { errorMessageRegistry } from '../errorRegistry/
|
|
2
|
+
import { errorMessageRegistry } from '../errorRegistry/errorRegistry.js';
|
|
3
3
|
export class AppError extends Error {
|
|
4
4
|
constructor(code, statusCode = HTTP_STATUS.SERVER_ERROR.INTERNAL_SERVER_ERROR, details, cause) {
|
|
5
5
|
super(errorMessageRegistry.resolve(code)); // message comes from mapping
|
package/dist/esm/error/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { AppError } from './AppError.js';
|
|
2
|
+
export { HTTPError } from './HTTPError.js';
|
|
3
3
|
// =========================
|
|
4
4
|
// 4xx Client Errors
|
|
5
5
|
// =========================
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
6
|
+
export { BadRequestError } from './BadRequestError.js';
|
|
7
|
+
export { UnauthorizedError } from './UnauthorizedError.js';
|
|
8
|
+
export { ForbiddenError } from './ForbiddenError.js';
|
|
9
|
+
export { NotFoundError } from './NotFoundError.js';
|
|
10
|
+
export { ConflictError } from './ConflictError.js';
|
|
11
|
+
export { ValidationError } from './ValidationError.js';
|
|
12
|
+
export { TooManyRequestsError } from './TooManyRequestsError.js';
|
|
13
13
|
// =========================
|
|
14
14
|
// Auth / Token Errors
|
|
15
15
|
// =========================
|
|
16
|
-
export
|
|
17
|
-
export
|
|
16
|
+
export { TokenExpiredError } from './TokenExpiredError.js';
|
|
17
|
+
export { TokenMalformedError } from './TokenMalformedError.js';
|
|
18
18
|
// =========================
|
|
19
19
|
// 5xx Server Errors
|
|
20
20
|
// =========================
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
21
|
+
export { InternalServerError } from './InternalServerError.js';
|
|
22
|
+
export { CryptoIntegrityError } from './CryptoIntegrityError.js';
|
|
23
|
+
export { ServiceUnavailableError } from './ServiceUnavailableError.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { expressErrorHandler } from './errorHandler.middleware.js';
|
|
2
|
+
export { errorConverter } from './errorConverter.middleware.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { expressErrorHandler, errorConverter } from './express/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { ERROR_CODES, type ErrorCode } from './errorCodes.js';
|
|
2
|
+
export { ERROR_MESSAGES } from './errorMessages.js';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
1
|
+
export { AppError } from './AppError.js';
|
|
2
|
+
export { HTTPError } from './HTTPError.js';
|
|
3
|
+
export { BadRequestError } from './BadRequestError.js';
|
|
4
|
+
export { UnauthorizedError } from './UnauthorizedError.js';
|
|
5
|
+
export { ForbiddenError } from './ForbiddenError.js';
|
|
6
|
+
export { NotFoundError } from './NotFoundError.js';
|
|
7
|
+
export { ConflictError } from './ConflictError.js';
|
|
8
|
+
export { ValidationError } from './ValidationError.js';
|
|
9
|
+
export { TooManyRequestsError } from './TooManyRequestsError.js';
|
|
10
|
+
export { TokenExpiredError } from './TokenExpiredError.js';
|
|
11
|
+
export { TokenMalformedError } from './TokenMalformedError.js';
|
|
12
|
+
export { InternalServerError } from './InternalServerError.js';
|
|
13
|
+
export { CryptoIntegrityError } from './CryptoIntegrityError.js';
|
|
14
|
+
export { ServiceUnavailableError } from './ServiceUnavailableError.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { expressErrorHandler } from './errorHandler.middleware.js';
|
|
2
|
+
export { errorConverter } from './errorConverter.middleware.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { expressErrorHandler, errorConverter } from './express/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naman_deep_singh/errors",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Standardized error classes and Express middleware for consistent error handling with TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"typescript": "^5.9.3"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@naman_deep_singh/http-response": "^3.2
|
|
54
|
+
"@naman_deep_singh/http-response": "^3.3.2"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|