throwy
v0.1.0
Published
Helper for throwing informative errors in Node.js and the browser
Readme
throwy
Helper for throwing informative errors in Node.js and the browser
Install
npm install throwyUsage
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'
})