Skip to content

Allow passing unknown values as cause - #91

Merged
Mrtenz merged 3 commits into
mainfrom
mrtenz/unknown-error
Apr 19, 2023
Merged

Allow passing unknown values as cause#91
Mrtenz merged 3 commits into
mainfrom
mrtenz/unknown-error

Conversation

@Mrtenz

Copy link
Copy Markdown
Member

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 ownerApril 19, 2023 09:21
Comment threadsrc/errors.test.ts
const error = rpcErrors.invalidInput({
data: {
foo: 'bar',
cause: 'foo',

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

null is used.

FrederikBolding
FrederikBolding previously approved these changes Apr 19, 2023
@Mrtenz
Mrtenz merged commit e06f8d8 into mainApr 19, 2023
@Mrtenz
Mrtenz deleted the mrtenz/unknown-error branch April 19, 2023 09:40
Sign up for freeto 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

@Mrtenz@FrederikBolding@legobeat