public
anord
read
Ledger
Why work hard when you can work easier?
Languages
Repository composition by tracked source files.
TypeScript
86%
CSS
10%
SQL
3%
Shell
1%
HTML
0%
Trace
apps/api/src/http/middleware/error-handler.ts
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
import type { NextFunction, Request, Response } from "express";
2
import { ZodError } from "zod";
4
export function errorHandler(error: unknown, _req: Request, res: Response, _next: NextFunction) {
5
if (error instanceof ZodError) {
6
return res.status(400).json({
7
error: "Validation failed",
8
details: error.flatten()
9
});
10
}
12
console.error(error);
13
return res.status(500).json({ error: "Internal server error" });
14
}