From e6c38550c66a668d19b9b27c215ddf4b73b053eb Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Tue, 2 Jul 2024 17:15:47 -0300 Subject: [PATCH] feat: add onError() function hono handler --- src/app.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/app.ts b/src/app.ts index 6a2205b4..2e7d8791 100644 --- a/src/app.ts +++ b/src/app.ts @@ -340,6 +340,13 @@ app.get('/', frontendController, indexController); // Fallback app.get('*', publicFiles, staticFiles, frontendController); +app.onError((err, c) => { + if (err.message === 'canceling statement due to statement timeout') { + return c.json({ error: 'Everything will be fine, I mean it. Don\t worry child.' }, 500); + } + return c.json(500); +}); + export default app; export type { AppContext, AppController, AppMiddleware };