mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
16 lines
507 B
TypeScript
16 lines
507 B
TypeScript
import { ErrorHandler } from '@hono/hono';
|
|
import { HTTPException } from '@hono/hono/http-exception';
|
|
|
|
export const errorHandler: ErrorHandler = (err, c) => {
|
|
if (err instanceof HTTPException) {
|
|
return c.json({ error: err.message }, err.status);
|
|
}
|
|
|
|
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);
|
|
};
|