Skip to content

Instantly share code, notes, and snippets.

View DonutEspresso's full-sized avatar

Alex Liu DonutEspresso

  • Netflix
  • California
View GitHub Profile
@DonutEspresso
DonutEspresso / asyncawait.js
Created May 17, 2019 01:45
Promise Error Model
'use strict';
const mockClient = {};
// The Promise model groups unintentional errors with errors into the same
// try/catch mechanism.
//
// In most typed languages this is fine because the catch clause gives you some
// flexibility to catch only the errors you are interested in. JS gives you a
// catch all, which makes it hard to distinguish the errors.
@DonutEspresso
DonutEspresso / callback.js
Created May 17, 2019 01:45
Callback Error Model
'use strict';
const mockClient = {};
// The Callback Error Model allows unintentional errors to bubble up and crash
// the process.
//
// With the Callback Error Model, it is impossible to catch these errors
// because try/catch doesn't work over subsequent ticks of the event loop.
//