UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const instance_1 = require("./instance");
4const StatusCode_1 = require("./StatusCode");
5class StormError extends Error {
6 constructor(details) {
7 super();
8 this.details = details;
9 const instance = instance_1.getInstance();
10 instance.getLogger().error(`${this.getMessage()}... See details below:`);
11 instance.getLogger().info(this.getPrivateDetails());
12 }
13 getPublicDetails() {
14 return {};
15 }
16 getPrivateDetails() {
17 return this.details;
18 }
19 getHTTPCode() {
20 return StatusCode_1.StatusCode.INTERNAL_ERROR;
21 }
22 getErrorResponse() {
23 let details = null;
24 if (this['getAdditionalDetails']) {
25 instance_1.getInstance().getLogger().deprecate('getPublicDetails', `${this.constructor.name}.getAdditionalDetails()`);
26 details = this['getAdditionalDetails']();
27 }
28 else {
29 details = this.getPublicDetails();
30 }
31 return {
32 name: this.constructor.name,
33 message: this.getMessage(),
34 code: this.getCode(),
35 details: details
36 };
37 }
38}
39exports.StormError = StormError;
40//# sourceMappingURL=StormError.js.map
\No newline at end of file