@common.js/serialize-error 11.0.1 → 11.0.2

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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +6 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  The [serialize-error](https://www.npmjs.com/package/serialize-error) package exported as CommonJS modules.
4
4
 
5
- Exported from [serialize-error@11.0.1](https://www.npmjs.com/package/serialize-error/v/11.0.1) using https://github.com/etienne-martin/common.js.
5
+ Exported from [serialize-error@11.0.2](https://www.npmjs.com/package/serialize-error/v/11.0.2) using https://github.com/etienne-martin/common.js.
package/index.js CHANGED
@@ -358,7 +358,10 @@ var destroyCircular = function(param) {
358
358
  continue;
359
359
  }
360
360
  if (!value || typeof value !== "object") {
361
- to[key] = value;
361
+ // Gracefully handle non-configurable errors like `DOMException`.
362
+ try {
363
+ to[key] = value;
364
+ } catch (e) {}
362
365
  continue;
363
366
  }
364
367
  if (!seen.includes(from[key])) {
@@ -427,9 +430,9 @@ function serializeError(value) {
427
430
  }
428
431
  // People sometimes throw things besides Error objects…
429
432
  if (typeof value === "function") {
430
- var _name;
431
433
  // `JSON.stringify()` discards functions. We do too, unless a function is thrown directly.
432
- return "[Function: ".concat((_name = value.name) !== null && _name !== void 0 ? _name : "anonymous", "]");
434
+ // We intentionally use `||` because `.name` is an empty string for anonymous functions.
435
+ return "[Function: ".concat(value.name || "anonymous", "]");
433
436
  }
434
437
  return value;
435
438
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common.js/serialize-error",
3
- "version": "11.0.1",
3
+ "version": "11.0.2",
4
4
  "description": "serialize-error package exported as CommonJS modules",
5
5
  "license": "MIT",
6
6
  "repository": "etienne-martin/common.js",