hono: catch HTTPException
This commit is contained in:
parent
0e6b4e8b45
commit
9ecf5db1b1
19
src/app.ts
19
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<AppEnv>();
|
|||
|
||||
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));
|
||||
|
|
Loading…
Reference in New Issue