@tryghost/mw-error-handler 0.1.0 → 0.1.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/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/mw-error-handler.js +5 -4
- package/package.json +4 -4
package/LICENSE
CHANGED
package/README.md
CHANGED
package/lib/mw-error-handler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const debug = require('@tryghost/debug')('error-handler');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
|
+
const {prepareStackForUser} = require('@tryghost/errors').utils;
|
|
4
5
|
const tpl = require('@tryghost/tpl');
|
|
5
6
|
|
|
6
7
|
const messages = {
|
|
@@ -77,7 +78,7 @@ module.exports.prepareError = (err, req, res, next) => {
|
|
|
77
78
|
// alternative for res.status();
|
|
78
79
|
res.statusCode = err.statusCode;
|
|
79
80
|
|
|
80
|
-
err
|
|
81
|
+
prepareStackForUser(err);
|
|
81
82
|
|
|
82
83
|
// never cache errors
|
|
83
84
|
res.set({
|
|
@@ -117,14 +118,14 @@ const jsonErrorRendererV2 = (err, req, res, next) => { // eslint-disable-line no
|
|
|
117
118
|
});
|
|
118
119
|
};
|
|
119
120
|
|
|
120
|
-
const prepareUserMessage = (err,
|
|
121
|
+
const prepareUserMessage = (err, req) => {
|
|
121
122
|
const userError = {
|
|
122
123
|
message: err.message,
|
|
123
124
|
context: err.context
|
|
124
125
|
};
|
|
125
126
|
|
|
126
|
-
const docName = _.get(
|
|
127
|
-
const method = _.get(
|
|
127
|
+
const docName = _.get(req, 'frameOptions.docName');
|
|
128
|
+
const method = _.get(req, 'frameOptions.method');
|
|
128
129
|
|
|
129
130
|
if (docName && method) {
|
|
130
131
|
let action;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mw-error-handler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"repository": "https://github.com/TryGhost/Utils/tree/main/packages/mw-error-handler",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "echo \"Implement me!\"",
|
|
10
|
-
"test": "NODE_ENV=testing c8 --check-coverage mocha './test/**/*.test.js'",
|
|
10
|
+
"test": "NODE_ENV=testing c8 --all --check-coverage --reporter text --reporter cobertura mocha './test/**/*.test.js'",
|
|
11
11
|
"lint": "eslint . --ext .js --cache",
|
|
12
12
|
"posttest": "yarn lint"
|
|
13
13
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"c8": "7.
|
|
22
|
+
"c8": "7.11.0",
|
|
23
23
|
"mocha": "9.1.3",
|
|
24
24
|
"should": "13.2.3",
|
|
25
25
|
"sinon": "12.0.1"
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"@tryghost/debug": "^0.1.9",
|
|
29
29
|
"@tryghost/tpl": "^0.1.8"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "66b978f9e41829822d5406699b7f67275606e2a2"
|
|
32
32
|
}
|