unthrow

0.1.1 • Public • Published

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.

Package Sidebar

Install

npm i unthrow

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • pcstl