Skip to content
Serialize an error into a plain object
Branch: master
Clone or download
Latest commit 30dfdfc Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig ES2015ify and require Node.js 4 May 23, 2017
.gitattributes Require Node.js 6 Oct 9, 2018
.gitignore
.npmrc Require Node.js 6 Oct 9, 2018
.travis.yml
index.d.ts
index.js Meta tweaks Mar 18, 2019
index.test-d.ts
license
package.json 4.0.0 Mar 18, 2019
readme.md Meta tweaks Mar 18, 2019
test.js Require Node.js 6 Oct 9, 2018

readme.md

serialize-error Build Status

Serialize an error into a plain object

Useful if you for example need to JSON.stringify() or process.send() the error.

Install

$ npm install serialize-error

Usage

const serializeError = require('serialize-error');

const error = new Error('🦄');

console.log(error);
//=> [Error: 🦄]

console.log(serializeError(error));
//=> {name: 'Error', message: '🦄', stack: 'Error: 🦄\n    at Object.<anonymous> …'}

License

MIT © Sindre Sorhus

You can’t perform that action at this time.