1.1.0 • Published 7 years ago

jsonerr v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

jsonerr

Converts an Error object into a JSON encodable object.

Example

const jsonerr = require('jsonerr')

let objErr = jsonerr(err)

Usage

`jsonerr(error, options)`

Options

NameDescriptionTypeDefault Value
stackInclude stack (parsed to an array)Booleantrue
enumerablesAn array with custom keys to include – or true to include all enumerables.Boolean or Arrayfalse

Example output

{ name: 'Error',
  message: 'This is an error',
  stack: [ { 
    function: 'repl', 
    file: undefined, 
    line: 1, 
    pos: 9 
  }, {
    function: 'sigintHandlersWrap',
    file: 'vm.js',
    line: 22,
    pos: 35
  }, { 
    function: 'sigintHandlersWrap',
    file: 'vm.js',
    line: 73,
    pos: 12
  }, { 
    function: 'ContextifyScript.Script.runInThisContext',
    file: 'vm.js',
    line: 21,
    pos: 12
  }, { 
    function: 'REPLServer.defaultEval',
    file: 'repl.js',
    line: 346,
    pos: 29
  }, { 
    function: 'bound', 
    file: 'domain.js', 
    line: 280, 
    pos: 14 
  }, { 
    function: 'eval', 
    file: 'domain.js', 
    line: 293, pos: 12
  }, {
    function: 'REPLServer.<anonymous>',
    file: 'repl.js',
    line: 545,
    pos: 10
  }, { 
    function: 'emitOne', 
    file: 'events.js', 
    line: 101, 
    pos: 20
  }, { 
    function: 'REPLServer.emit',
    file: 'events.js',
    line: 188,
    pos: 7
  } ] }