@expressots/core 1.4.0 → 1.4.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 +7 -11
- package/lib/README.md +7 -11
- package/lib/cjs/controller/base-controller.js +2 -2
- package/lib/cjs/error/error-handler-middleware.js +1 -3
- package/lib/cjs/error/index.js +1 -3
- package/lib/cjs/error/report.js +26 -2
- package/lib/cjs/logger/general-logger.js +2 -2
- package/lib/cjs/types/error/error-handler-middleware.d.ts +3 -3
- package/lib/cjs/types/error/error-handler-middleware.d.ts.map +1 -1
- package/lib/cjs/types/error/index.d.ts +0 -1
- package/lib/cjs/types/error/index.d.ts.map +1 -1
- package/lib/cjs/types/error/report.d.ts +10 -3
- package/lib/cjs/types/error/report.d.ts.map +1 -1
- package/lib/esm/controller/base-controller.js +2 -2
- package/lib/esm/error/error-handler-middleware.js +1 -3
- package/lib/esm/error/index.js +0 -1
- package/lib/esm/error/report.js +26 -2
- package/lib/esm/logger/general-logger.js +2 -2
- package/lib/esm/types/error/error-handler-middleware.d.ts +3 -3
- package/lib/esm/types/error/error-handler-middleware.d.ts.map +1 -1
- package/lib/esm/types/error/index.d.ts +0 -1
- package/lib/esm/types/error/index.d.ts.map +1 -1
- package/lib/esm/types/error/report.d.ts +10 -3
- package/lib/esm/types/error/report.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/error/application-error.js +0 -37
- package/lib/cjs/types/error/application-error.d.ts +0 -18
- package/lib/cjs/types/error/application-error.d.ts.map +0 -1
- package/lib/esm/error/application-error.js +0 -36
- package/lib/esm/types/error/application-error.d.ts +0 -18
- package/lib/esm/types/error/application-error.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -32,13 +32,15 @@ The [Issue Reporting Channel](https://github.com/expressots/expressots/issues) i
|
|
|
32
32
|
|
|
33
33
|
Before you create an issue, please make sure you read the [Contribution Guidelines](CONTRIBUTING.md).
|
|
34
34
|
|
|
35
|
-
## Support
|
|
35
|
+
## Support the project
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Expresso TS is an MIT-licensed open source project. It's an independent project with ongoing development made possible thanks to your support. If you'd like to help, please consider:
|
|
38
38
|
|
|
39
|
-
- Become a sponsor on GitHub
|
|
40
|
-
- Follow the organization on GitHub and Star the project
|
|
41
|
-
-
|
|
39
|
+
- Become a sponsor on **[Sponsor no GitHub](https://github.com/sponsors/expressots)**
|
|
40
|
+
- Follow the **[organization](https://github.com/expressots)** on GitHub and Star ⭐ the project
|
|
41
|
+
- Subscribe to the Twitch channel: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
|
|
42
|
+
- Join our **[Discord](https://discord.com/invite/PyPJfGK)**
|
|
43
|
+
- Contribute submitting **[issues and pull requests](https://github.com/expressots/expressots/issues/new/choose)**
|
|
42
44
|
- Share the project with your friends and colleagues
|
|
43
45
|
|
|
44
46
|
## Contributors
|
|
@@ -54,12 +56,6 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
|
|
|
54
56
|
|
|
55
57
|
- Work in progress
|
|
56
58
|
|
|
57
|
-
## Stay in touch
|
|
58
|
-
|
|
59
|
-
- Author: Richard Zampieri
|
|
60
|
-
- Website: [https://expresso-ts.com](https://expresso-ts.com)
|
|
61
|
-
- Twitch channel: [Richard Zampieri](https://www.twitch.tv/richardzampieri)
|
|
62
|
-
|
|
63
59
|
## License
|
|
64
60
|
|
|
65
61
|
ExpressoTS is **[MIT licensed](LICENSE.md)**
|
package/lib/README.md
CHANGED
|
@@ -32,13 +32,15 @@ The [Issue Reporting Channel](https://github.com/expressots/expressots/issues) i
|
|
|
32
32
|
|
|
33
33
|
Before you create an issue, please make sure you read the [Contribution Guidelines](CONTRIBUTING.md).
|
|
34
34
|
|
|
35
|
-
## Support
|
|
35
|
+
## Support the project
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Expresso TS is an MIT-licensed open source project. It's an independent project with ongoing development made possible thanks to your support. If you'd like to help, please consider:
|
|
38
38
|
|
|
39
|
-
- Become a sponsor on GitHub
|
|
40
|
-
- Follow the organization on GitHub and Star the project
|
|
41
|
-
-
|
|
39
|
+
- Become a sponsor on **[Sponsor no GitHub](https://github.com/sponsors/expressots)**
|
|
40
|
+
- Follow the **[organization](https://github.com/expressots)** on GitHub and Star ⭐ the project
|
|
41
|
+
- Subscribe to the Twitch channel: **[Richard Zampieri](https://www.twitch.tv/richardzampieri)**
|
|
42
|
+
- Join our **[Discord](https://discord.com/invite/PyPJfGK)**
|
|
43
|
+
- Contribute submitting **[issues and pull requests](https://github.com/expressots/expressots/issues/new/choose)**
|
|
42
44
|
- Share the project with your friends and colleagues
|
|
43
45
|
|
|
44
46
|
## Contributors
|
|
@@ -54,12 +56,6 @@ ExpressoTS is an MIT-licensed open source project. It's an independent project w
|
|
|
54
56
|
|
|
55
57
|
- Work in progress
|
|
56
58
|
|
|
57
|
-
## Stay in touch
|
|
58
|
-
|
|
59
|
-
- Author: Richard Zampieri
|
|
60
|
-
- Website: [https://expresso-ts.com](https://expresso-ts.com)
|
|
61
|
-
- Twitch channel: [Richard Zampieri](https://www.twitch.tv/richardzampieri)
|
|
62
|
-
|
|
63
59
|
## License
|
|
64
60
|
|
|
65
61
|
ExpressoTS is **[MIT licensed](LICENSE.md)**
|
|
@@ -49,7 +49,7 @@ let BaseController = BaseController_1 = class BaseController {
|
|
|
49
49
|
return res.status(successStatusCode).json(dataReturn);
|
|
50
50
|
}
|
|
51
51
|
catch (error) {
|
|
52
|
-
error_1.Report.Error(error);
|
|
52
|
+
error_1.Report.Error(error, undefined, this.serviceName);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -66,7 +66,7 @@ let BaseController = BaseController_1 = class BaseController {
|
|
|
66
66
|
return res.status(successStatusCode).json(dataReturn);
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
error_1.Report.Error(error);
|
|
69
|
+
error_1.Report.Error(error, undefined, this.serviceName);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const status_code_1 = require("./status-code");
|
|
4
|
-
const logger_1 = require("../logger");
|
|
5
4
|
/**
|
|
6
5
|
* errorHandler is a custom Express error-handling middleware function.
|
|
7
6
|
* It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
|
|
8
|
-
* @param error - An instance of
|
|
7
|
+
* @param error - An instance of IAppError containing error details.
|
|
9
8
|
* @param req - The Express request object.
|
|
10
9
|
* @param res - The Express response object.
|
|
11
10
|
* @param next - The Express next function for passing control to the next middleware function.
|
|
12
11
|
*/
|
|
13
12
|
function errorHandler(error, req, res, next) {
|
|
14
|
-
(0, logger_1.log)(logger_1.LogLevel.Error, error, error.service || "service-undefined");
|
|
15
13
|
res.status(error.statusCode || status_code_1.StatusCode.InternalServerError).json({ statusCode: error.statusCode, error: error.message });
|
|
16
14
|
}
|
|
17
15
|
exports.default = errorHandler;
|
package/lib/cjs/error/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Report = exports.
|
|
3
|
+
exports.Report = exports.StatusCode = void 0;
|
|
4
4
|
var status_code_1 = require("./status-code");
|
|
5
5
|
Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return status_code_1.StatusCode; } });
|
|
6
|
-
var application_error_1 = require("./application-error");
|
|
7
|
-
Object.defineProperty(exports, "AppError", { enumerable: true, get: function () { return application_error_1.AppError; } });
|
|
8
6
|
var report_1 = require("./report");
|
|
9
7
|
Object.defineProperty(exports, "Report", { enumerable: true, get: function () { return report_1.Report; } });
|
package/lib/cjs/error/report.js
CHANGED
|
@@ -9,6 +9,7 @@ var Report_1;
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.Report = void 0;
|
|
11
11
|
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
12
|
+
const logger_1 = require("../logger");
|
|
12
13
|
/**
|
|
13
14
|
* Report class is a utility class to manage and throw application-specific errors.
|
|
14
15
|
*/
|
|
@@ -17,8 +18,31 @@ let Report = Report_1 = class Report {
|
|
|
17
18
|
* Error method takes an instance of AppError and throws it.
|
|
18
19
|
* @param error - An instance of AppError containing error details.
|
|
19
20
|
*/
|
|
20
|
-
static Error(error) {
|
|
21
|
-
|
|
21
|
+
static Error(error, statusCode, service) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
let appError = {};
|
|
24
|
+
Error.captureStackTrace(this, this.Error);
|
|
25
|
+
const callerName = (_b = (_a = this.stack.split("\n")[1]) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.split(" ")[1];
|
|
26
|
+
if (error instanceof Error) {
|
|
27
|
+
appError = {
|
|
28
|
+
statusCode: statusCode !== null && statusCode !== void 0 ? statusCode : 500,
|
|
29
|
+
message: error.message,
|
|
30
|
+
service: service !== null && service !== void 0 ? service : callerName,
|
|
31
|
+
name: error.name,
|
|
32
|
+
stack: error.stack
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
appError = {
|
|
37
|
+
statusCode: statusCode !== null && statusCode !== void 0 ? statusCode : 500,
|
|
38
|
+
message: error,
|
|
39
|
+
service: service !== null && service !== void 0 ? service : callerName,
|
|
40
|
+
name: this.Error.name,
|
|
41
|
+
stack: this.stack
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
(0, logger_1.log)(logger_1.LogLevel.Error, appError, appError.service || "service-undefined");
|
|
45
|
+
throw appError;
|
|
22
46
|
}
|
|
23
47
|
};
|
|
24
48
|
Report = Report_1 = __decorate([
|
|
@@ -40,8 +40,8 @@ let GeneralLogger = GeneralLogger_1 = class GeneralLogger {
|
|
|
40
40
|
*/
|
|
41
41
|
createConsoleTransport() {
|
|
42
42
|
const consoleTransport = new winston_1.transports.Console({
|
|
43
|
-
level: "debug",
|
|
44
|
-
handleExceptions:
|
|
43
|
+
level: (process.env.ENVIRONMENT !== "Development" && "debug") || "debug",
|
|
44
|
+
handleExceptions: false,
|
|
45
45
|
handleRejections: true
|
|
46
46
|
});
|
|
47
47
|
return consoleTransport;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from "express";
|
|
2
|
-
import {
|
|
2
|
+
import { IAppError } from "./report";
|
|
3
3
|
/**
|
|
4
4
|
* errorHandler is a custom Express error-handling middleware function.
|
|
5
5
|
* It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
|
|
6
|
-
* @param error - An instance of
|
|
6
|
+
* @param error - An instance of IAppError containing error details.
|
|
7
7
|
* @param req - The Express request object.
|
|
8
8
|
* @param res - The Express response object.
|
|
9
9
|
* @param next - The Express next function for passing control to the next middleware function.
|
|
10
10
|
*/
|
|
11
|
-
declare function errorHandler(error:
|
|
11
|
+
declare function errorHandler(error: IAppError, req: Request, res: Response, next: NextFunction): void;
|
|
12
12
|
export default errorHandler;
|
|
13
13
|
//# sourceMappingURL=error-handler-middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler-middleware.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/error-handler-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"error-handler-middleware.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/error-handler-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIrC;;;;;;;GAOG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAE7F;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
interface IAppError {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
message: string;
|
|
4
|
+
service?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* Report class is a utility class to manage and throw application-specific errors.
|
|
4
10
|
*/
|
|
5
11
|
declare class Report {
|
|
12
|
+
static stack: string;
|
|
6
13
|
/**
|
|
7
14
|
* Error method takes an instance of AppError and throws it.
|
|
8
15
|
* @param error - An instance of AppError containing error details.
|
|
9
16
|
*/
|
|
10
|
-
static Error(error:
|
|
17
|
+
static Error(error: Error | string, statusCode?: number, service?: string): void;
|
|
11
18
|
}
|
|
12
|
-
export { Report };
|
|
19
|
+
export { Report, IAppError };
|
|
13
20
|
//# sourceMappingURL=report.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/report.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/report.ts"],"names":[],"mappings":"AAGA,UAAU,SAAS;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD;;GAEG;AACH,cACM,MAAM;IACR,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IAErB;;;OAGG;WACW,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;CA6B1F;AAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -37,7 +37,7 @@ let BaseController = BaseController_1 = class BaseController {
|
|
|
37
37
|
return res.status(successStatusCode).json(dataReturn);
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
|
-
Report.Error(error);
|
|
40
|
+
Report.Error(error, undefined, this.serviceName);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -53,7 +53,7 @@ let BaseController = BaseController_1 = class BaseController {
|
|
|
53
53
|
return res.status(successStatusCode).json(dataReturn);
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
56
|
-
Report.Error(error);
|
|
56
|
+
Report.Error(error, undefined, this.serviceName);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { StatusCode } from "./status-code";
|
|
2
|
-
import { LogLevel, log } from "../logger";
|
|
3
2
|
/**
|
|
4
3
|
* errorHandler is a custom Express error-handling middleware function.
|
|
5
4
|
* It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
|
|
6
|
-
* @param error - An instance of
|
|
5
|
+
* @param error - An instance of IAppError containing error details.
|
|
7
6
|
* @param req - The Express request object.
|
|
8
7
|
* @param res - The Express response object.
|
|
9
8
|
* @param next - The Express next function for passing control to the next middleware function.
|
|
10
9
|
*/
|
|
11
10
|
function errorHandler(error, req, res, next) {
|
|
12
|
-
log(LogLevel.Error, error, error.service || "service-undefined");
|
|
13
11
|
res.status(error.statusCode || StatusCode.InternalServerError).json({ statusCode: error.statusCode, error: error.message });
|
|
14
12
|
}
|
|
15
13
|
export default errorHandler;
|
package/lib/esm/error/index.js
CHANGED
package/lib/esm/error/report.js
CHANGED
|
@@ -6,16 +6,40 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
var Report_1;
|
|
8
8
|
import { provide } from "inversify-binding-decorators";
|
|
9
|
+
import { LogLevel, log } from '../logger';
|
|
9
10
|
/**
|
|
10
11
|
* Report class is a utility class to manage and throw application-specific errors.
|
|
11
12
|
*/
|
|
12
13
|
let Report = Report_1 = class Report {
|
|
14
|
+
static stack;
|
|
13
15
|
/**
|
|
14
16
|
* Error method takes an instance of AppError and throws it.
|
|
15
17
|
* @param error - An instance of AppError containing error details.
|
|
16
18
|
*/
|
|
17
|
-
static Error(error) {
|
|
18
|
-
|
|
19
|
+
static Error(error, statusCode, service) {
|
|
20
|
+
let appError = {};
|
|
21
|
+
Error.captureStackTrace(this, this.Error);
|
|
22
|
+
const callerName = this.stack.split("\n")[1]?.trim()?.split(" ")[1];
|
|
23
|
+
if (error instanceof Error) {
|
|
24
|
+
appError = {
|
|
25
|
+
statusCode: statusCode ?? 500,
|
|
26
|
+
message: error.message,
|
|
27
|
+
service: service ?? callerName,
|
|
28
|
+
name: error.name,
|
|
29
|
+
stack: error.stack
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
appError = {
|
|
34
|
+
statusCode: statusCode ?? 500,
|
|
35
|
+
message: error,
|
|
36
|
+
service: service ?? callerName,
|
|
37
|
+
name: this.Error.name,
|
|
38
|
+
stack: this.stack
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
log(LogLevel.Error, appError, appError.service || "service-undefined");
|
|
42
|
+
throw appError;
|
|
19
43
|
}
|
|
20
44
|
};
|
|
21
45
|
Report = Report_1 = __decorate([
|
|
@@ -34,8 +34,8 @@ let GeneralLogger = GeneralLogger_1 = class GeneralLogger {
|
|
|
34
34
|
*/
|
|
35
35
|
createConsoleTransport() {
|
|
36
36
|
const consoleTransport = new transports.Console({
|
|
37
|
-
level: "debug",
|
|
38
|
-
handleExceptions:
|
|
37
|
+
level: (process.env.ENVIRONMENT !== "Development" && "debug") || "debug",
|
|
38
|
+
handleExceptions: false,
|
|
39
39
|
handleRejections: true
|
|
40
40
|
});
|
|
41
41
|
return consoleTransport;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from "express";
|
|
2
|
-
import {
|
|
2
|
+
import { IAppError } from "./report";
|
|
3
3
|
/**
|
|
4
4
|
* errorHandler is a custom Express error-handling middleware function.
|
|
5
5
|
* It logs the error, sets the status code, and sends a JSON response containing the status code and error message.
|
|
6
|
-
* @param error - An instance of
|
|
6
|
+
* @param error - An instance of IAppError containing error details.
|
|
7
7
|
* @param req - The Express request object.
|
|
8
8
|
* @param res - The Express response object.
|
|
9
9
|
* @param next - The Express next function for passing control to the next middleware function.
|
|
10
10
|
*/
|
|
11
|
-
declare function errorHandler(error:
|
|
11
|
+
declare function errorHandler(error: IAppError, req: Request, res: Response, next: NextFunction): void;
|
|
12
12
|
export default errorHandler;
|
|
13
13
|
//# sourceMappingURL=error-handler-middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler-middleware.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/error-handler-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"error-handler-middleware.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/error-handler-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIrC;;;;;;;GAOG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAE7F;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
interface IAppError {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
message: string;
|
|
4
|
+
service?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* Report class is a utility class to manage and throw application-specific errors.
|
|
4
10
|
*/
|
|
5
11
|
declare class Report {
|
|
12
|
+
static stack: string;
|
|
6
13
|
/**
|
|
7
14
|
* Error method takes an instance of AppError and throws it.
|
|
8
15
|
* @param error - An instance of AppError containing error details.
|
|
9
16
|
*/
|
|
10
|
-
static Error(error:
|
|
17
|
+
static Error(error: Error | string, statusCode?: number, service?: string): void;
|
|
11
18
|
}
|
|
12
|
-
export { Report };
|
|
19
|
+
export { Report, IAppError };
|
|
13
20
|
//# sourceMappingURL=report.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/report.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/report.ts"],"names":[],"mappings":"AAGA,UAAU,SAAS;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD;;GAEG;AACH,cACM,MAAM;IACR,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;IAErB;;;OAGG;WACW,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;CA6B1F;AAED,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var AppError_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.AppError = void 0;
|
|
14
|
-
const inversify_binding_decorators_1 = require("inversify-binding-decorators");
|
|
15
|
-
/**
|
|
16
|
-
* The AppError class extends the built-in Error class, adding a status code and service property.
|
|
17
|
-
* It is designed for handling application-specific errors with more detailed information.
|
|
18
|
-
* @provide AppError
|
|
19
|
-
*/
|
|
20
|
-
let AppError = AppError_1 = class AppError extends Error {
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new AppError instance.
|
|
23
|
-
* @param statusCode - The status code associated with the error.
|
|
24
|
-
* @param message - The error message.
|
|
25
|
-
* @param service - An optional service name related to the error.
|
|
26
|
-
*/
|
|
27
|
-
constructor(statusCode, message, service) {
|
|
28
|
-
super(message);
|
|
29
|
-
this.statusCode = statusCode;
|
|
30
|
-
this.service = service;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
AppError = AppError_1 = __decorate([
|
|
34
|
-
(0, inversify_binding_decorators_1.provide)(AppError_1),
|
|
35
|
-
__metadata("design:paramtypes", [Number, String, String])
|
|
36
|
-
], AppError);
|
|
37
|
-
exports.AppError = AppError;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The AppError class extends the built-in Error class, adding a status code and service property.
|
|
3
|
-
* It is designed for handling application-specific errors with more detailed information.
|
|
4
|
-
* @provide AppError
|
|
5
|
-
*/
|
|
6
|
-
declare class AppError extends Error {
|
|
7
|
-
statusCode: number;
|
|
8
|
-
service: string;
|
|
9
|
-
/**
|
|
10
|
-
* Constructs a new AppError instance.
|
|
11
|
-
* @param statusCode - The status code associated with the error.
|
|
12
|
-
* @param message - The error message.
|
|
13
|
-
* @param service - An optional service name related to the error.
|
|
14
|
-
*/
|
|
15
|
-
constructor(statusCode: number, message: string, service?: string);
|
|
16
|
-
}
|
|
17
|
-
export { AppError };
|
|
18
|
-
//# sourceMappingURL=application-error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application-error.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/application-error.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,cACM,QAAS,SAAQ,KAAK;IAEjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;gBACS,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAMpE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var AppError_1;
|
|
11
|
-
import { provide } from "inversify-binding-decorators";
|
|
12
|
-
/**
|
|
13
|
-
* The AppError class extends the built-in Error class, adding a status code and service property.
|
|
14
|
-
* It is designed for handling application-specific errors with more detailed information.
|
|
15
|
-
* @provide AppError
|
|
16
|
-
*/
|
|
17
|
-
let AppError = AppError_1 = class AppError extends Error {
|
|
18
|
-
statusCode;
|
|
19
|
-
service;
|
|
20
|
-
/**
|
|
21
|
-
* Constructs a new AppError instance.
|
|
22
|
-
* @param statusCode - The status code associated with the error.
|
|
23
|
-
* @param message - The error message.
|
|
24
|
-
* @param service - An optional service name related to the error.
|
|
25
|
-
*/
|
|
26
|
-
constructor(statusCode, message, service) {
|
|
27
|
-
super(message);
|
|
28
|
-
this.statusCode = statusCode;
|
|
29
|
-
this.service = service;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
AppError = AppError_1 = __decorate([
|
|
33
|
-
provide(AppError_1),
|
|
34
|
-
__metadata("design:paramtypes", [Number, String, String])
|
|
35
|
-
], AppError);
|
|
36
|
-
export { AppError };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The AppError class extends the built-in Error class, adding a status code and service property.
|
|
3
|
-
* It is designed for handling application-specific errors with more detailed information.
|
|
4
|
-
* @provide AppError
|
|
5
|
-
*/
|
|
6
|
-
declare class AppError extends Error {
|
|
7
|
-
statusCode: number;
|
|
8
|
-
service: string;
|
|
9
|
-
/**
|
|
10
|
-
* Constructs a new AppError instance.
|
|
11
|
-
* @param statusCode - The status code associated with the error.
|
|
12
|
-
* @param message - The error message.
|
|
13
|
-
* @param service - An optional service name related to the error.
|
|
14
|
-
*/
|
|
15
|
-
constructor(statusCode: number, message: string, service?: string);
|
|
16
|
-
}
|
|
17
|
-
export { AppError };
|
|
18
|
-
//# sourceMappingURL=application-error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application-error.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/error/application-error.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,cACM,QAAS,SAAQ,KAAK;IAEjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;gBACS,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAMpE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|