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
|
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
|
## Author
|
||||||
|
|
||||||
Yusuke Wada <https://github.com/yusukebe>
|
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 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 => {
|
export const sentry = (): Handler => {
|
||||||
return async (c, next) => {
|
return async (c, next) => {
|
||||||
// const sentry = new Toucan({
|
Sentry.init({
|
||||||
// dsn: c.env.SENTRY_DSN || || c.env.NEXT_PUBLIC_SENTRY_DSN,
|
dsn: c.env.SENTRY_DSN || c.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||||
// request: c.req,
|
tracesSampleRate: 1.0,
|
||||||
// allowedHeaders: ['user-agent'],
|
})
|
||||||
// allowedSearchParams: /(.*)/,
|
try {
|
||||||
// })
|
await next()
|
||||||
|
} catch (error) {
|
||||||
// try {
|
Sentry.captureException(error)
|
||||||
await next()
|
throw error
|
||||||
// } catch (error) {
|
}
|
||||||
// sentry.captureException(error)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ export const sentry = (): Handler => {
|
||||||
await next()
|
await next()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
sentry.captureException(error)
|
sentry.captureException(error)
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue