Reputation: 712
I am fairly new to NodeJS and just started using Async/Await utility for handling the control flow. Now for the module q, we have the following to handle the error cases gracefully:
async_function().then(
resolve_function(resolved_data){
},
reject_function(rejected_data){
}
)
Where the resolve_function gets the resolved values from defer.resolve and reject_function gets the values from defer.reject.
Is there a same utility available for Async/Await where we could explicitly resolve or reject certain values based on a business logic rather than falling back to try/catch which doesn't handle the logical errors.
Upvotes: 1
Views: 640
Reputation:
Q make use of promises, which is an entirely different paradigm from the async callbacks you'd normally see in some of the modules.
The good thing about using promises is that you can chain several calls and just have 1 method to catch and handle all the errors.
Upvotes: 1