Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs.util.inspect.custom support for uncaught Errors #54272

Open
underflow00 opened this issue Aug 8, 2024 · 1 comment
Open

nodejs.util.inspect.custom support for uncaught Errors #54272

underflow00 opened this issue Aug 8, 2024 · 1 comment
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.

Comments

@underflow00
Copy link

underflow00 commented Aug 8, 2024

What is the problem this feature will solve?

When an Error/object is thrown and not caught, the error information printed to the terminal does not consider the [Symbol.for("nodejs.util.inspect.custom")]() function. https://nodejs.org/api/util.html#utilinspectcustom
This is potentially a bug.

class C1 {
    [Symbol.for("nodejs.util.inspect.custom")]() {
        return "custom string";
    }
}
console.log(new C1()); // custom string appears
throw new C1() // custom string does not appear

What is the feature you are proposing to solve the problem?

Add nodejs.util.inspect.custom function support for uncaught Errors

What alternatives have you considered?

No response

@underflow00 underflow00 added the feature request Issues that request new features to be added to Node.js. label Aug 8, 2024
@BridgeAR
Copy link
Member

BridgeAR commented Aug 8, 2024

AFAIC it is intentional to not trigger custom inspection in case of a crash. The reason is that a crash is probably not anticipated and custom inspection could hide details. It could also add more, so it's definitely a trade-off. It would theoretically be possible to log both but the question is also how to print that.

@RedYetiDev RedYetiDev added the util Issues and PRs related to the built-in util module. label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.
Projects
Status: Awaiting Triage
Development

No branches or pull requests

3 participants