npm.io
0.1.0 • Published 7 years ago

err-json

Licence
MIT
Version
0.1.0
Deps
0
Size
3 kB
Vulns
0
Weekly
0

err-json

Convert Error to JSON.

Installation

npm i err-json

Usage

const {
  errJson,
  errJsonDebug,
} = require('err-json');

const json1 = errJson(err);

const json2 = errJson(err, true);

errJson(err)

Returns an object with the following properties:

  • name
    • A name of the error.
  • message
    • Error message.
  • code
    • Error code.

errJsonDebug(err, split = false)

Returns an object with the following properties:

  • name
    • A name of the error.
  • message
    • Error message.
  • code
    • Error code.
  • stack
    • Stack trace.
    • If the argument split is true, it is returned as an array.

License

MIT

Keywords