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

Allow passing unknown values as cause #91

Merged
merged 3 commits into from
Apr 19, 2023
Merged

Allow passing unknown values as cause #91

merged 3 commits into from
Apr 19, 2023

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Apr 19, 2023

Description

This pull request is to enable unknown values to be used as the cause of an error. Previously, only the Error type
was allowed as a cause of error. However, any value may cause an error to occur, not just an Error value. Therefore,
it becomes necessary to allow other types to be used as error causes.

Changes

  1. Allow unknown values as error causes.

Previously, only the `Error` type as accepted as cause, but since any value can be thrown as error, we have to allow any value to be used.
@Mrtenz Mrtenz requested a review from a team as a code owner April 19, 2023 09:21
const error = rpcErrors.invalidInput({
data: {
foo: 'bar',
cause: 'foo',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when this is not JSON-serializable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null is used.

@Mrtenz Mrtenz merged commit e06f8d8 into main Apr 19, 2023
@Mrtenz Mrtenz deleted the mrtenz/unknown-error branch April 19, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants