You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportclassCustomErrorextendsError{// ... tell me if you need the whole class. But the point is, that this.cause is returned inside `toJSON`toJSON(): Record<string,unknown>{return{message: this.message,name: this.name,cause: this.cause,};}}
Steps to Reproduce
Set up a custom error class that has a toJSON method, which includes the this.cause property.
Throw an error which has such error in its cause. E.g.
I just tested this out and had a look at our code, indeed if cause is an Error or if a value of a property inside the JSON returned from toJSON is an Error it gets immediately serialized via toString regardless of having a toJSON itself.
This is something we can consider changing, I'll bring it up with the team. Otherwise, we also welcome contributions if you're interested.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
8.51.0
Framework Version
Next 15.1.3
Link to Sentry event
https://sally-and-friends.sentry.io/issues/6215894150/events/2b86efb54ff54674bac3bd0582bc1952/
Reproduction Example/SDK Setup
// sentry.server.config (same for the other two)
// my custom error class' toJSON
Steps to Reproduce
toJSON
method, which includes thethis.cause
property.cause
. E.g.Expected Result
The top-level error is getting serialized, including the extra error data.
The
cause
field is another structured error data. E.g.because capturing the
cause
is enabled by default.Actual Result
The nested error getting serialized in the format `${errorClassName}: ${message} instead of the whole structured data.
The text was updated successfully, but these errors were encountered: