@athenna/http 1.2.2 → 1.2.3
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/package.json +1 -1
- package/src/Handlers/HttpErrorHandler.js +10 -12
package/package.json
CHANGED
|
@@ -17,26 +17,24 @@ class HttpErrorHandler {
|
|
|
17
17
|
const code = error.code || error.name;
|
|
18
18
|
const statusCode = error.statusCode || error.status || 500;
|
|
19
19
|
const body = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
stack: error.stack,
|
|
26
|
-
},
|
|
20
|
+
statusCode,
|
|
21
|
+
code: utils_1.String.toSnakeCase(`${code}`).toUpperCase(),
|
|
22
|
+
name: error.name,
|
|
23
|
+
message: error.message,
|
|
24
|
+
stack: error.stack,
|
|
27
25
|
};
|
|
28
26
|
if (error.help) {
|
|
29
|
-
body.
|
|
27
|
+
body.help = error.help;
|
|
30
28
|
}
|
|
31
29
|
const isInternalServerError = statusCode === 500;
|
|
32
30
|
const isDebugMode = config_1.Config.get('app.debug');
|
|
33
31
|
if (isInternalServerError && !isDebugMode) {
|
|
34
|
-
body.
|
|
35
|
-
body.
|
|
36
|
-
delete body.
|
|
32
|
+
body.name = 'Internal server error';
|
|
33
|
+
body.message = 'An internal server exception has occurred.';
|
|
34
|
+
delete body.stack;
|
|
37
35
|
}
|
|
38
36
|
if (isDebugMode) {
|
|
39
|
-
new logger_1.Logger().error(`Error: ${JSON.stringify(body
|
|
37
|
+
new logger_1.Logger().error(`Error: ${JSON.stringify(body, null, 2)}`, {
|
|
40
38
|
formatterConfig: {
|
|
41
39
|
context: HttpErrorHandler.name,
|
|
42
40
|
},
|