@articulate/paperplane-bugsnag
v0.3.0
Published
A bugsnag wrapper for paperplane
Downloads
8
Maintainers
Readme
Usage
Setup your bugsnag
like this:
// server/lib/bugsnag.js
const bugsnag = require('bugsnag')
const bugsnagClient = bugsnag({
apiKey: process.env.BUGSNAG_API_KEY,
notifyReleaseStages: ['prod', 'stage'],
releaseStage: process.env.SERVICE_ENV
})
const optionalCustomLogger =
err => console.error(`My custom logged error: ${err.message}`)
module.exports = require('paperplane-bugsnag')(bugsnagClient, optionalCustomLogger)
Then use it as the cry
option in paperplane
like this:
// server/index.js
const http = require('http')
const { mount } = require('paperplane')
const app = require('./rest')
const cry = require('./lib/bugsnag').notify
http.createServer(mount({ app, cry })).listen(3000, cry)
By default, Boom
client errors (4xx) and Joi
validitation errors will be ignored.
// server/rest.js
module.exports = req => {
const err = Boom.badRequest()
return Promise.reject(err) // does not send notification
}
We can force a notification by setting cry=true
on the error.
// server/rest.js
module.exports = req => {
const err = Boom.badRequest()
err.cry = true
return Promise.reject(err) // sends notification
}