Awesome
JavaScript error handling examples
This is a collection of various JavaScript error handling techniques.
- synchronous
synchronous-return-value
: indicate error through return valuesynchronous-exception
: throw an exception if an error occurs
- asynchronous
error-callbacks
: call additional error callbackerror-callbacks-node
: call regular callback with error argumentpromises
: return a promise objectdomain-bound-execptions
: use Node.js domains
Usage
Run a file without arguments to watch it fail; pass an argument for success.
$ ./promises.js
Letter not sent: Cannot reach address empty
$ ./promises.js London
Letter sent with code XYZ-London
Read more
This code accompanies the blog post Asynchronous error handling in JavaScript, which discusses the use case.