Hacker News new | ask | show | jobs
by warfangle 3899 days ago
The alternative JavaScript version:

    let some_func = (callback) => callback(new Error('boom'))

    let some_other_func = (err) => console.log(err || 'everything is fine')
What makes a huge difference is when you write async code with generators, coroutines and promises:

    let some_func = co(function*() {
        try { 
            const someData = yield asyncRequest(some_url);
            console.log('asyncRequest resolved with %j', someData)
        }
        catch(e) {
            console.log('asyncRequest rejected with %j', e);
        }
    });