Move errorHandler to a separate file

This commit is contained in:
Alex Gleason
2024-07-04 23:53:20 +01:00
parent 8923a5ee55
commit d4713cae01
2 changed files with 13 additions and 6 deletions

11
src/controllers/error.ts Normal file
View File

@@ -0,0 +1,11 @@
import { ErrorHandler } from '@hono/hono';
export const errorHandler: ErrorHandler = (err, c) => {
console.error(err);
if (err.message === 'canceling statement due to statement timeout') {
return c.json({ error: 'The server was unable to respond in a timely manner' }, 500);
}
return c.json({ error: 'Something went wrong' }, 500);
};