Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 864 Bytes

README.md

File metadata and controls

61 lines (41 loc) · 864 Bytes

NOTICE

Sentry now provides official Koa integration: https://sentry.io/for/koa/.

koa-raven

raven middleware for koa.

Install

$ npm i koa-raven --save

Usage

raven(DSN[, opts])

const raven = require('koa-raven')
const Koa = require('koa')
const app = new Koa()

app.use(raven('DSN', opts))

app.use((ctx) => {
  throw new Error('test')
})

app.listen(3000)

or:

const raven = require('koa-raven')
const Koa = require('koa')
const app = new Koa()

app.use(raven('DSN', opts))

app.use((ctx) => {
  try {
    throw new Error('test')
  } catch (e) {
    ctx.raven.captureException(e, { extra: { name: 'tom' } })
    ctx.status = 500
    ctx.body = e.stack
  }
})

app.listen(3000)

Options

see: https://docs.sentry.io/clients/node/config/.

License

MIT