simple-errors
Factory methods for easy error handling.
Installation
npm install simple-errors
Usage
Just make sure to require the module somewhere in your code (only once)
;
Then use the factory methods for creating errors:
//simplest of errorsvar err = Error; //with messagevar err = Error;console; //prints true //with datavar err = Error;console; //prints trueconsole; //prints true //with data and inner errorvar err = Error;console; //prints trueconsole; //prints trueconsole; //prints true //helper for status codes (for use with connect & express)var err = Error;console; //prints true //helper for status codes, with message, data and errorvar err = Error;console; //prints trueconsole; //prints trueconsole; //prints trueconsole; //prints true //helper method for turning the Error instance into a json objectvar err = Error;var obj = Error; //use this to print the entire error with stack.