0.1.1 • Published 7 years ago

unthrow v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

unthrow

Build Status Dependencies Status

JavaScript Promises are awesome, but they have a fundamental issue: When you use a Promise, you mix up your asynchronicity-handling code with your error-handling code through .catch. Unthrow fixes this, making you free to handle possible errors wherever you want to.

Usage

Just wrap your calls to Promise-returning function which may fail with unthrow. The result of an unthrowed call is a new Promise which will yield a Result. A Result is a plain JavaScript object with a status field.

The value of the status field may be "Ok" or "Error".

If the value of status is "Ok", the Result will have a value field containing the result of the promise. If the value of status is "Error", the Result will have an error field containing the error thrown by the promise.