mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
feat(api): ✨ Add global server error handler
This commit is contained in:
parent
23d091f7ce
commit
7f48c990e7
13
app.ts
13
app.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { errorResponse, response } from "@/response";
|
||||
import { errorResponse, jsonResponse, response } from "@/response";
|
||||
import { Hono } from "@hono/hono";
|
||||
import { getLogger } from "@logtape/logtape";
|
||||
import { config } from "config-manager";
|
||||
|
|
@ -93,6 +93,17 @@ export const appFactory = async () => {
|
|||
return proxy;
|
||||
});
|
||||
|
||||
app.onError((error) => {
|
||||
return jsonResponse(
|
||||
{
|
||||
error: "A server error occured",
|
||||
name: error.name,
|
||||
message: error.message,
|
||||
},
|
||||
500,
|
||||
);
|
||||
});
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue