@tryghost/errors 1.2.4 → 1.2.7

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.
Files changed (2) hide show
  1. package/lib/utils.js +5 -2
  2. package/package.json +4 -3
package/lib/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const omit = require('lodash/omit');
2
2
  const merge = require('lodash/merge');
3
3
  const extend = require('lodash/extend');
4
+ const cloneError = require('utils-copy-error');
4
5
  const _private = {};
5
6
 
6
7
  _private.serialize = function serialize(err) {
@@ -180,6 +181,7 @@ exports.deserialize = function deserialize(errorFormat) {
180
181
  /**
181
182
  * @description Replace the stack with a user-facing one
182
183
  * @params {Error} err
184
+ * @returns {Error} Clone of the original error with a user-facing stack
183
185
  */
184
186
  exports.prepareStackForUser = function prepareStackForUser(error) {
185
187
  let stackbits = error.stack.split(/\n/);
@@ -202,8 +204,9 @@ exports.prepareStackForUser = function prepareStackForUser(error) {
202
204
  stackbits.splice(1, 0, `${error.context}`);
203
205
  }
204
206
 
205
- error.stack = stackbits.join('\n');
206
- return error;
207
+ const errorClone = cloneError(error);
208
+ errorClone.stack = stackbits.join('\n');
209
+ return errorClone;
207
210
  };
208
211
 
209
212
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/errors",
3
- "version": "1.2.4",
3
+ "version": "1.2.7",
4
4
  "repository": "https://github.com/TryGhost/framework/tree/main/packages/errors",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -20,13 +20,14 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "c8": "7.11.0",
23
- "mocha": "9.2.1",
23
+ "mocha": "9.2.2",
24
24
  "should": "13.2.3",
25
25
  "sinon": "13.0.1"
26
26
  },
27
27
  "dependencies": {
28
28
  "lodash": "^4.17.21",
29
+ "utils-copy-error": "^1.0.1",
29
30
  "uuid": "^8.3.2"
30
31
  },
31
- "gitHead": "3768b2b29fe5c2ae4e535264246bc78933eba372"
32
+ "gitHead": "782447b7c96a800387ef83ad4a2a330615918399"
32
33
  }