@tryghost/mw-error-handler 0.1.2 → 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.
@@ -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: [{
@@ -177,6 +181,8 @@ module.exports.handleJSONResponse = sentry => [
177
181
  module.exports.prepareError,
178
182
  // Handle the error in Sentry
179
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
  ];
@@ -186,6 +192,8 @@ module.exports.handleJSONResponseV2 = sentry => [
186
192
  module.exports.prepareError,
187
193
  // Handle the error in Sentry
188
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
  ];
@@ -194,6 +202,8 @@ module.exports.handleHTMLResponse = sentry => [
194
202
  // Make sure the error can be served
195
203
  module.exports.prepareError,
196
204
  // Handle the error in Sentry
197
- sentry.errorHandler
205
+ sentry.errorHandler,
206
+ // Format the stack for the user
207
+ module.exports.prepareStack
198
208
  ];
199
209
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@tryghost/mw-error-handler",
3
- "version": "0.1.2",
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",
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
  },
@@ -26,7 +26,9 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@tryghost/debug": "^0.1.9",
29
- "@tryghost/tpl": "^0.1.8"
29
+ "@tryghost/errors": "1.2.5",
30
+ "@tryghost/tpl": "^0.1.8",
31
+ "lodash": "4.17.21"
30
32
  },
31
- "gitHead": "d9374c7c0a1bd92f53b4bf330797a890cdae7e6d"
33
+ "gitHead": "64b09915cbfd97d139bf8360a79b36a0f45fc552"
32
34
  }