Skip to content

coproduto/unthrow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unthrow

NPM 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.

About

Wrap promises, never use .catch again

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published