throwy

0.1.0 • Public • Published

throwy

Helper for throwing informative errors in Node.js and the browser

Install

npm install throwy

Usage

var throwy = require('throwy')
 
try {
    throwy({
        msg: 'Could not connect to db',
        connString: 'postgresql://postgres:admin@localhost:5432/master'
    })
} catch (ex){
    ex.toString() // is equivalent to JSON.stringify on the above object
    ex.message //is the msg from above object
}
 

You can configure throwy to call a function for you whenever a throwy error is thrown

 
throwy.configure({
    onError: function(err, details){
        console.log('Cause :' + details.cause)
        //will log
        //"Cause: server is shut down"
    }
})
 
throwy({
    msg: 'failure',
    cause: 'server is shut down'
})

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    0

Package Sidebar

Install

npm i throwy

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • radubrehar