@tryghost/mw-error-handler 0.1.4 → 0.1.5
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/lib/mw-error-handler.js +18 -8
- package/package.json +2 -2
package/lib/mw-error-handler.js
CHANGED
|
@@ -78,8 +78,6 @@ module.exports.prepareError = (err, req, res, next) => {
|
|
|
78
78
|
// alternative for res.status();
|
|
79
79
|
res.statusCode = err.statusCode;
|
|
80
80
|
|
|
81
|
-
prepareStackForUser(err);
|
|
82
|
-
|
|
83
81
|
// never cache errors
|
|
84
82
|
res.set({
|
|
85
83
|
'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'
|
|
@@ -88,6 +86,12 @@ module.exports.prepareError = (err, req, res, next) => {
|
|
|
88
86
|
next(err);
|
|
89
87
|
};
|
|
90
88
|
|
|
89
|
+
module.exports.prepareStack = (err, req, res, next) => { // eslint-disable-line no-unused-vars
|
|
90
|
+
const clonedError = prepareStackForUser(err);
|
|
91
|
+
|
|
92
|
+
next(clonedError);
|
|
93
|
+
};
|
|
94
|
+
|
|
91
95
|
const jsonErrorRenderer = (err, req, res, next) => { // eslint-disable-line no-unused-vars
|
|
92
96
|
res.json({
|
|
93
97
|
errors: [{
|
|
@@ -173,27 +177,33 @@ module.exports.pageNotFound = (req, res, next) => {
|
|
|
173
177
|
};
|
|
174
178
|
|
|
175
179
|
module.exports.handleJSONResponse = sentry => [
|
|
176
|
-
// Handle the error in Sentry
|
|
177
|
-
sentry.errorHandler,
|
|
178
180
|
// Make sure the error can be served
|
|
179
181
|
module.exports.prepareError,
|
|
182
|
+
// Handle the error in Sentry
|
|
183
|
+
sentry.errorHandler,
|
|
184
|
+
// Format the stack for the user
|
|
185
|
+
module.exports.prepareStack,
|
|
180
186
|
// Render the error using JSON format
|
|
181
187
|
jsonErrorRenderer
|
|
182
188
|
];
|
|
183
189
|
|
|
184
190
|
module.exports.handleJSONResponseV2 = sentry => [
|
|
185
|
-
// Handle the error in Sentry
|
|
186
|
-
sentry.errorHandler,
|
|
187
191
|
// Make sure the error can be served
|
|
188
192
|
module.exports.prepareError,
|
|
193
|
+
// Handle the error in Sentry
|
|
194
|
+
sentry.errorHandler,
|
|
195
|
+
// Format the stack for the user
|
|
196
|
+
module.exports.prepareStack,
|
|
189
197
|
// Render the error using JSON format
|
|
190
198
|
jsonErrorRendererV2
|
|
191
199
|
];
|
|
192
200
|
|
|
193
201
|
module.exports.handleHTMLResponse = sentry => [
|
|
202
|
+
// Make sure the error can be served
|
|
203
|
+
module.exports.prepareError,
|
|
194
204
|
// Handle the error in Sentry
|
|
195
205
|
sentry.errorHandler,
|
|
196
|
-
//
|
|
197
|
-
module.exports.
|
|
206
|
+
// Format the stack for the user
|
|
207
|
+
module.exports.prepareStack
|
|
198
208
|
];
|
|
199
209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mw-error-handler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"repository": "https://github.com/TryGhost/Utils/tree/main/packages/mw-error-handler",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@tryghost/tpl": "^0.1.8",
|
|
31
31
|
"lodash": "4.17.21"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "64b09915cbfd97d139bf8360a79b36a0f45fc552"
|
|
34
34
|
}
|