Neural Processing Mechanisms

    errsome

    1.0.1 • Public • Published

    errsome

    Making errors more loggable, readable and serializable, but still object.

    Build Status NPM version

    Why?

    There is some problems with Error object in node.js, so why not try to handle it?

    Synopsis

    ~/js/github/errsome $ node
    > const errsome = require('.')
    undefined
    > const err = new TypeError('This is a message\nMulti line')
    undefined
    > err.field = 'bla'
    'bla'
    > err
    { TypeError: This is a message
    Multi line
        at repl:1:13
        at ContextifyScript.Script.runInThisContext (vm.js:50:33)
        at REPLServer.defaultEval (repl.js:239:29)
        at bound (domain.js:301:14)
        at REPLServer.runBound [as eval] (domain.js:314:12)
        at REPLServer.onLine (repl.js:440:10)
        at emitOne (events.js:120:20)
        at REPLServer.emit (events.js:210:7)
        at REPLServer.Interface._onLine (readline.js:282:10)
        at REPLServer.Interface._line (readline.js:631:8) field: 'bla' }
    > errsome(err)
    { name: 'TypeError',
      message: ['This is a message', 'Multi line'],
      stack:
       [ 'at repl:1:13',
         'at ContextifyScript.Script.runInThisContext (vm.js:50:33)',
         'at REPLServer.defaultEval (repl.js:239:29)',
         'at bound (domain.js:301:14)',
         'at REPLServer.runBound [as eval] (domain.js:314:12)',
         'at REPLServer.onLine (repl.js:440:10)',
         'at emitOne (events.js:120:20)',
         'at REPLServer.emit (events.js:210:7)',
         'at REPLServer.Interface._onLine (readline.js:282:10)',
         'at REPLServer.Interface._line (readline.js:631:8)' ],
      field: 'bla' }
    >
    

    Install

    npm i errsome

    Usage

    const errsome = require('errsome');
     
    const err = new Error('Bla-bla-bla');
     
    const awesomeError = errsome(err);
     
    const serializedError = errsome.stringify(err, 2);
    // It is just a short form for this:
    // require('json5').stringify(err, null, 2);
     
    errsome.log(err, 2);
    // It is just a short form for this:
    // console.log(errsome.stringify(err, 2));

    License

    MIT

    Install

    npm i errsome

    DownloadsWeekly Downloads

    25

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    6.75 kB

    Total Files

    8

    Last publish

    Collaborators

    • astur