Created
September 20, 2017 20:41
-
-
Save ccnixon/422bac0ebff7fd2294c092959ae01a0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function track (msg) { | |
return Promise.resolve(foo) // intentially triggering ReferenceError for undefined `foo` | |
} | |
async function process (msg, done) { | |
try { | |
const res = await track(msg) | |
return done(null, res) | |
} catch (e) { | |
// If an err code hasn't been applied, we can assume this was uncaught by the integration's own err handler. | |
err.code = err.code || 'INTERNAL' | |
err.retry = true | |
return done(err) | |
} | |
} | |
function onMessage (msg) { | |
process(msg, (err, res) => { | |
// log err/res to datadog or whatever... | |
if (err) { | |
stats.err(err) | |
} else { | |
stats.success(res) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment