@tryghost/mw-error-handler 0.1.0 → 0.1.1

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.
@@ -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 = err.prepareErrorForUser();
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, res) => {
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(res, 'frameOptions.docName');
127
- const method = _.get(res, 'frameOptions.method');
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mw-error-handler",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "repository": "https://github.com/TryGhost/Utils/tree/main/packages/mw-error-handler",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -28,5 +28,5 @@
28
28
  "@tryghost/debug": "^0.1.9",
29
29
  "@tryghost/tpl": "^0.1.8"
30
30
  },
31
- "gitHead": "b1b11d0f5f788981c846984346c420aa50d55899"
31
+ "gitHead": "8ecf8264002298829fbce686a1bd0ad413e2e01b"
32
32
  }