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:
@@ -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" });
|
||||
|
||||
Reference in New Issue
Block a user