fix: add centralized error handler for unhandled exceptions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 15:34:51 +02:00
parent ecff58500e
commit 41a2910aeb

View File

@@ -18,6 +18,16 @@ seedDefaults();
const app = new Hono();
// Centralized error handler
app.onError((err, c) => {
console.error(`[${c.req.method}] ${c.req.path}:`, err);
const message =
process.env.NODE_ENV === "production"
? "Internal server error"
: err.message || "Internal server error";
return c.json({ error: message }, 500);
});
// Health check
app.get("/api/health", (c) => {
return c.json({ status: "ok" });