-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix: preserve the type of failures that are instances of Error #13
Conversation
@iamchanii what does the following code mean: if (Cause.isAnnotatedType(result.cause) && Cause.isFailType(result.cause.cause)) {
throw result.cause.cause.error;
} and how would I be able to return an annotated type as an alternative to this fix? |
@vecerek At least when I implemented,
But now we got just Failed exit. so
It means |
src/field-builder.ts
Outdated
if (Cause.isFailType(result.cause) && (result.cause.error as any instanceof Error)) { | ||
throw result.cause.error; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result.cause.error
could can be not an instance of Error
. so it should be wraped by failErrorConstructor
, effectOptions.defaultFailErrorConstructor
or Error
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be misunderstanding you but that's exactly the reason for which I'm also checking if result.cause.error instanceof Error
in the above code. If it isn't, I want it to fall through and be handled by the throw logic below:
throw new (effect.failErrorConstructor ?? effectOptions?.defaultFailErrorConstructor ?? Error)(
Cause.pretty(result.cause),
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh yep. you're right.
iamchanii#13 (comment) Co-authored-by: Chanhee Lee <contact@imch.dev>
fyi: there might be situated that Ref: https://canary.discord.com/channels/795981131316985866/1141586320624468068 |
Fixes #12