diff --git a/src/app.ts b/src/app.ts index 6143b6c..c759be3 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,13 @@ import { NostrEvent, NStore } from '@nostrify/nostrify'; -import { type Context, Env as HonoEnv, type Handler, Hono, Input as HonoInput, type MiddlewareHandler } from 'hono'; +import { + type Context, + Env as HonoEnv, + type Handler, + Hono, + HTTPException, + Input as HonoInput, + type MiddlewareHandler, +} from 'hono'; import { cors, logger, serveStatic } from 'hono/middleware'; import { Conf } from '@/config.ts'; @@ -103,9 +111,16 @@ const app = new Hono(); if (Conf.sentryDsn) { // @ts-ignore Mismatched hono types. - app.use('*', sentryMiddleware({ dsn: Conf.sentryDsn, ignoreErrors: 'HTTPException' })); + app.use('*', sentryMiddleware({ dsn: Conf.sentryDsn })); } +app.onError((err) => { + if (err instanceof HTTPException) { + return err.getResponse(); + } + throw err; +}); + const debug = Debug('ditto:http'); app.use('/api/*', logger(debug));