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