nest icon indicating copy to clipboard operation
nest copied to clipboard

Base exception filter ignores exception cause

Open jeengbe opened this issue 9 months ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

The base exception filter (https://github.com/nestjs/nest/blob/master/packages/core/exceptions/base-exception-filter.ts#L72-L75) simply drops any properties on errors other than message and stack, especially cause. This is very unfortunate as cause is when provided often crucial to understanding an error.

Minimum reproduction code

n/a

Steps to reproduce

No response

Expected behavior

Additional properties, especially cause should not simply be ignored, but forwarded to the logger.

Package

  • [ ] I don't know. Or some 3rd-party package
  • [ ] @nestjs/common
  • [X] @nestjs/core
  • [ ] @nestjs/microservices
  • [ ] @nestjs/platform-express
  • [ ] @nestjs/platform-fastify
  • [ ] @nestjs/platform-socket.io
  • [ ] @nestjs/platform-ws
  • [ ] @nestjs/testing
  • [ ] @nestjs/websockets
  • [ ] Other (see below)

Other package

No response

NestJS version

No response

Packages versions

n/a

Node.js version

No response

In which operating systems have you tested?

  • [ ] macOS
  • [ ] Windows
  • [ ] Linux

Other

No response

jeengbe avatar May 08 '24 10:05 jeengbe

Would you like to create a PR for this issue?

kamilmysliwiec avatar May 21 '24 06:05 kamilmysliwiec

I have little understanding of what's happening with the error and why message and stack are logged explicitly. I guess the change would require more refactoring than just my simple patch, sorry.

jeengbe avatar May 21 '24 09:05 jeengbe

Hi @micalevisk, @kamilmysliwiec I'm interested in working on this issue and improving the base-exception-filter

ZigBalthazar avatar Jun 04 '24 08:06 ZigBalthazar

I've created a PR #13681

Could you take a look? :)

jochongs avatar Jun 13 '24 08:06 jochongs

Let's track this here https://github.com/nestjs/nest/pull/13870

kamilmysliwiec avatar Aug 09 '24 07:08 kamilmysliwiec