[QUESTION] "failed with status code 500" output instead of detailed error message
See original GitHub issueWhen I’m throwing an error from Nest application nestjs-pino always prints in the error message “failed with status code 500” even though I’m throwing an error with a detailed message any idea how to solve this?
this is how I setup nestjs-pino
LoggerModule.forRoot({
pinoHttp: {
prettyPrint: { colorize: true, translateTime: true },
serializers: {
req: (req) => ({
...req,
headers: undefined,
}),
res: (res) => ({
...res,
headers: undefined,
}),
},
},
}),
and this is how I throw the error
import {InternalServerErrorException} from '@nestjs/common';
throw new InternalServerErrorException("This is my detailed error");
And nestjs-pino output
res: {
"statusCode": 500
}
err: {
"type": "Error",
"message": "failed with status code 500",
"stack":
Error: failed with status code 500
at ServerResponse.onResFinished (/Users/shahaf/Source/muil/muil/node_modules/pino-http/logger.js:73:38)
at ServerResponse.clsBind (/Users/shahaf/Source/muil/muil/node_modules/cls-hooked/context.js:172:17)
at ServerResponse.emit (node:events:388:22)
at ServerResponse.EventEmitter.emit (node:domain:532:15)
at ServerResponse.emitted (/Users/shahaf/Source/muil/muil/node_modules/emitter-listener/listener.js:134:21)
at onFinish (node:_http_outgoing:800:10)
at callback (node:internal/streams/writable:557:21)
at afterWrite (node:internal/streams/writable:503:5)
at afterWriteTick (node:internal/streams/writable:490:10)
at processTicksAndRejections (node:internal/process/task_queues:79:21)
}
responseTime: 94
req: {
"id": 1,
"method": "POST",
"url": "/api/test/test",
"remoteAddress": "::1",
"remotePort": 61221
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to Fix a 500 Internal Server Error - Lifewire
The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the website's server, but...
Read more >HTTP Error 500 – Internal Server Error Explained in Plain ...
The 500 (Internal Server Error) status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the ...
Read more >HTTP 500 Internal Server Error: What It Means & How to Fix It
An HTTP 500 internal server error is a general error message. It covers unexpected issues that don't fit into existing error codes.
Read more >How to Fix a 500 Internal Server Error on Your WordPress Site
The 500 Internal Server Error status code occurs when the server encounters an error that prevents it from fulfilling the request.
Read more >How to fix HTTP 500 internal server error? - IONOS
The situation is different with the 400 and 500 status codes. While the former indicate client errors, the latter are server-related.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any suggestion/ work around for the above?
Done