mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 10:30:37 +09:00
Improve 500 error logging with actual error details and correct log levels
pino-http was logging 500s at INFO level with a generic "failed with status code 500" message. Now 500s log at ERROR level and include the actual error (message, stack, name) via res.locals handoff from the error handler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3ae112acff
commit
758a5538c5
2 changed files with 28 additions and 1 deletions
|
|
@ -26,6 +26,9 @@ export function errorHandler(
|
|||
? { message: err.message, stack: err.stack, name: err.name }
|
||||
: { raw: err };
|
||||
|
||||
// Attach the real error so pino-http can include it in its response log
|
||||
res.locals.serverError = errObj;
|
||||
|
||||
logger.error(
|
||||
{ err: errObj, method: req.method, url: req.originalUrl },
|
||||
"Unhandled error: %s %s — %s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue