We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The HttpExceptionOptions.cause type is strictly Error | undefined which requires client-side handling with TypeScript's useUnknownInCatchVariables flag (enabled by default in v4.4), i.e.
HttpExceptionOptions.cause
Error | undefined
useUnknownInCatchVariables
try { // ... } catch (error) { throw new UnauthorizedException(undefined, { cause: error instanceof Error ? error : undefined, }); }
It would be nice to loosen the type to unknown (with internal conditional logic).
unknown
The proposed solution would simplify the client-side implementation:
try { // ... } catch (cause) { throw new UnauthorizedException(undefined, { cause }); }
This would enable TypeScript users to more easily leverage Error.cause.
Error.cause
The text was updated successfully, but these errors were encountered:
Would you like to create a PR for this issue?
Sorry, something went wrong.
Sure!
fix(common): loosen http exception cause type
41552d3
resolves nestjs#11665
Let's track this here #11673
No branches or pull requests
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
The
HttpExceptionOptions.cause
type is strictlyError | undefined
which requires client-side handling with TypeScript'suseUnknownInCatchVariables
flag (enabled by default in v4.4), i.e.Describe the solution you'd like
It would be nice to loosen the type to
unknown
(with internal conditional logic).Teachability, documentation, adoption, migration strategy
The proposed solution would simplify the client-side implementation:
What is the motivation / use case for changing the behavior?
This would enable TypeScript users to more easily leverage
Error.cause
.The text was updated successfully, but these errors were encountered: