@akanjs/nest 0.9.54 → 0.9.55
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/cjs/src/exceptions.js +10 -12
- package/esm/src/exceptions.js +11 -13
- package/package.json +1 -1
package/cjs/src/exceptions.js
CHANGED
|
@@ -52,21 +52,19 @@ ${exception.stack}`
|
|
|
52
52
|
const req = ctx.getRequest();
|
|
53
53
|
const reqType = req.method;
|
|
54
54
|
const reqName = req.url;
|
|
55
|
-
const status = exception instanceof import_common2.HttpException ? exception.getStatus() :
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`Http Error: ${status}
|
|
55
|
+
const status = exception instanceof import_common2.HttpException ? exception.getStatus() : import_common2.HttpStatus.INTERNAL_SERVER_ERROR;
|
|
56
|
+
res.status(status).json({
|
|
57
|
+
statusCode: status,
|
|
58
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
59
|
+
path: req.url,
|
|
60
|
+
message: exception instanceof import_common2.HttpException ? exception.getResponse() : exception.message
|
|
61
|
+
});
|
|
62
|
+
this.logger.error(
|
|
63
|
+
`Http Error: ${status}
|
|
65
64
|
Request: ${reqType}-${reqName}
|
|
66
65
|
Body: ${JSON.stringify(req.body, null, 2)}
|
|
67
66
|
${exception.stack}`
|
|
68
|
-
|
|
69
|
-
}
|
|
67
|
+
);
|
|
70
68
|
}
|
|
71
69
|
};
|
|
72
70
|
AllExceptionsFilter = __decorateClass([
|
package/esm/src/exceptions.js
CHANGED
|
@@ -10,7 +10,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
return result;
|
|
11
11
|
};
|
|
12
12
|
import { Logger } from "@akanjs/common";
|
|
13
|
-
import { Catch, HttpException } from "@nestjs/common";
|
|
13
|
+
import { Catch, HttpException, HttpStatus } from "@nestjs/common";
|
|
14
14
|
let AllExceptionsFilter = class {
|
|
15
15
|
logger = new Logger("Exception Filter");
|
|
16
16
|
catch(exception, host) {
|
|
@@ -32,21 +32,19 @@ ${exception.stack}`
|
|
|
32
32
|
const req = ctx.getRequest();
|
|
33
33
|
const reqType = req.method;
|
|
34
34
|
const reqName = req.url;
|
|
35
|
-
const status = exception instanceof HttpException ? exception.getStatus() :
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`Http Error: ${status}
|
|
35
|
+
const status = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
|
|
36
|
+
res.status(status).json({
|
|
37
|
+
statusCode: status,
|
|
38
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39
|
+
path: req.url,
|
|
40
|
+
message: exception instanceof HttpException ? exception.getResponse() : exception.message
|
|
41
|
+
});
|
|
42
|
+
this.logger.error(
|
|
43
|
+
`Http Error: ${status}
|
|
45
44
|
Request: ${reqType}-${reqName}
|
|
46
45
|
Body: ${JSON.stringify(req.body, null, 2)}
|
|
47
46
|
${exception.stack}`
|
|
48
|
-
|
|
49
|
-
}
|
|
47
|
+
);
|
|
50
48
|
}
|
|
51
49
|
};
|
|
52
50
|
AllExceptionsFilter = __decorateClass([
|