Skip to content

Instantly share code, notes, and snippets.

@ccnixon
Created September 20, 2017 20:41
Show Gist options
  • Save ccnixon/422bac0ebff7fd2294c092959ae01a0d to your computer and use it in GitHub Desktop.
Save ccnixon/422bac0ebff7fd2294c092959ae01a0d to your computer and use it in GitHub Desktop.
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