@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-2021 Ghost Foundation
3
+ Copyright (c) 2013-2022 Ghost Foundation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -36,4 +36,4 @@ Follow the instructions for the top-level repo.
36
36
 
37
37
  # Copyright & License
38
38
 
39
- Copyright (c) 2013-2021 Ghost Foundation - Released under the [MIT license](LICENSE).
39
+ Copyright (c) 2013-2022 Ghost Foundation - Released under the [MIT license](LICENSE).
@@ -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,13 +1,13 @@
1
1
  {
2
2
  "name": "@tryghost/mw-error-handler",
3
- "version": "0.1.0",
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.10.0",
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": "b1b11d0f5f788981c846984346c420aa50d55899"
31
+ "gitHead": "66b978f9e41829822d5406699b7f67275606e2a2"
32
32
  }