Created
December 14, 2016 07:00
-
-
Save chrisyip/10f1a4ab50e20513d946ebdc8f19ca1e to your computer and use it in GitHub Desktop.
A promise version of Sentry.captureError.
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
'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