Async await wrapper for easy error handling without try-catch
$ npm install await-call
const call = require('await-call');
const findUserById = async id => {
if(Math.random() > .5)
throw Error('BOOM!');
return { name: 'lsong' };
};
const cb = err => {
console.error('Oh! No..', err);
};
(async () => {
const [ err, user ] = await call(findUserById(1));
if(err) return cb('user not found');
console.log(`hello ${user.name}`);
})();
- Fork this Repo first
- Clone your Repo
- Install dependencies by
$ npm install
- Checkout a feature branch
- Feel free to add your features
- Make sure your features are fully tested
- Publish your local branch, Open a pull request
- Enjoy hacking <3
This work is licensed under the MIT license.