Skip to content

Instantly share code, notes, and snippets.

@chrisyip
Created December 14, 2016 07:00
Show Gist options
  • Save chrisyip/10f1a4ab50e20513d946ebdc8f19ca1e to your computer and use it in GitHub Desktop.
Save chrisyip/10f1a4ab50e20513d946ebdc8f19ca1e to your computer and use it in GitHub Desktop.
A promise version of Sentry.captureError.
'use strict'
const Raven = require('raven')
exports.capture = function (err, options = {}) {
return new Promise((resolve, reject) => {
const client = new Raven.Client(RAVEN_DSN)
const listener = res => {
client.removeListener('logged', listener)
resolve(res)
}
client.once('logged', listener)
.once('error', err => {
client.removeListener('logged', listener)
reject(err)
})
client.captureError(err, options)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment