chore: bump up Hono; support new error handling (#6)

pull/31/head
Yusuke Wada 2022-10-10 00:57:51 +09:00 committed by GitHub
parent a85c140e66
commit 2460e82976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -33,7 +33,7 @@
"access": "public" "access": "public"
}, },
"dependencies": { "dependencies": {
"hono": "^2.0.6", "hono": "^2.2.5",
"toucan-js": "^2.6.1" "toucan-js": "^2.6.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -48,11 +48,9 @@ export const sentry = (options?: Options, callback?: (sentry: Toucan) => void):
c.set('sentry', sentry) c.set('sentry', sentry)
if (callback) callback(sentry) if (callback) callback(sentry)
try {
await next() await next()
} catch (error) { if (c.error) {
sentry.captureException(error) sentry.captureException(c.error)
throw error
} }
} }
} }

View File

@ -21,6 +21,8 @@ describe('Sentry middleware', () => {
app.use('/sentry/*', sentry(undefined, callback)) app.use('/sentry/*', sentry(undefined, callback))
app.get('/sentry/foo', (c) => c.text('foo')) app.get('/sentry/foo', (c) => c.text('foo'))
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
app.get('/sentry/bar', (c) => getSentry(c).log('bar') || c.text('bar')) app.get('/sentry/bar', (c) => getSentry(c).log('bar') || c.text('bar'))
app.get('/sentry/error', () => { app.get('/sentry/error', () => {
throw new Error('a catastrophic error') throw new Error('a catastrophic error')

View File

@ -2280,10 +2280,10 @@ has@^1.0.3:
dependencies: dependencies:
function-bind "^1.1.1" function-bind "^1.1.1"
hono@^2.0.6: hono@^2.2.5:
version "2.0.6" version "2.2.5"
resolved "https://registry.yarnpkg.com/hono/-/hono-2.0.6.tgz#fa4b17905a6fb187114beef3eebce13f163de99b" resolved "https://registry.yarnpkg.com/hono/-/hono-2.2.5.tgz#c0258d796d1e48e2b83b76f915a24c14fdf4f289"
integrity sha512-HgtiYdmBm4gayQ/IEUNbzQgBlEQdoN57F8A8QmtlqqoCgNvFNZ7J7KKEHiZHm4sviZ0SndBhQMlvkjupW0J3rg== integrity sha512-qIOLwQYJrTGwSSLahXvQ60nJT+NhZqsf+zSvj3eitBPCxpb+bsA2cl4clJzo1WNB+3KdxAdfVmUzq2stzby3eg==
html-escaper@^2.0.0: html-escaper@^2.0.0:
version "2.0.2" version "2.0.2"