Deno library + re-throw error
parent
9294150029
commit
b47e0004e2
15
README.md
15
README.md
|
@ -17,6 +17,21 @@ app.get('/', (c) => c.text('foo'))
|
|||
export default app
|
||||
```
|
||||
|
||||
## Deno
|
||||
|
||||
```ts
|
||||
import { serve } from 'https://deno.land/std/http/server.ts'
|
||||
import { sentry } from 'https://deno.land/x/hono_sentry/mod.ts'
|
||||
import { Hono } from 'https://deno.land/x/hono/mod.ts'
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
app.use('*', sentry())
|
||||
app.get('/', (c) => c.text('foo'))
|
||||
|
||||
serve(app.fetch)
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
Yusuke Wada <https://github.com/yusukebe>
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
import type { Handler } from 'https://raw.githubusercontent.com/honojs/hono/v2.0.6/deno_dist/mod.ts'
|
||||
// import Toucan from '../node_modules/toucan-js/dist/index.d.ts'
|
||||
import * as Sentry from 'https://deno.land/x/sentry_deno/main.ts'
|
||||
|
||||
export const sentry = (): Handler => {
|
||||
return async (c, next) => {
|
||||
// const sentry = new Toucan({
|
||||
// dsn: c.env.SENTRY_DSN || || c.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
// request: c.req,
|
||||
// allowedHeaders: ['user-agent'],
|
||||
// allowedSearchParams: /(.*)/,
|
||||
// })
|
||||
|
||||
// try {
|
||||
await next()
|
||||
// } catch (error) {
|
||||
// sentry.captureException(error)
|
||||
// }
|
||||
Sentry.init({
|
||||
dsn: c.env.SENTRY_DSN || c.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
tracesSampleRate: 1.0,
|
||||
})
|
||||
try {
|
||||
await next()
|
||||
} catch (error) {
|
||||
Sentry.captureException(error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ export const sentry = (): Handler => {
|
|||
await next()
|
||||
} catch (error) {
|
||||
sentry.captureException(error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue