question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] "failed with status code 500" output instead of detailed error message

See original GitHub issue

When 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
gmathavadoss-chwycommented, Jan 25, 2021

Any suggestion/ work around for the above?

1reaction
kasvithcommented, Sep 6, 2021

Done

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found