serialize-error

2018-10-14 admin

serialize-error是什么

什么是serialize-error,Serialize an error into a plain object

serialize-error使用教程帮助文档

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('unicorn');

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

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

License

MIT © Sindre Sorhus

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-42628.html

文章标题:serialize-error

回到顶部