-
Notifications
You must be signed in to change notification settings - Fork 23
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
try() function #3137
try() function #3137
Conversation
🦋 Changeset detectedLatest commit: 978658c The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
[ | ||
frNamed("fn", frLambdaTyped([], frAny({ genericName: "A" }))), | ||
// in the future, this function could be called with the error message | ||
frNamed("fallbackFn", frLambdaTyped([], frAny({ genericName: "A" }))), |
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.
Not sure that we should use a generic like this here.
As a user, I'd probably be inclined to use a different type in a lot of cases.
Like, try({|| 2+''}, {|| {type: error, message: "X failed" })
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.
Yeah, technically the output type should be a union of both functions' return types, but we don't have unions in frTypes.
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.
What about frOr()
?
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.
Ah, you're right, I forgot about it.
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.
Fixed here: 22f7435
// This doesn't looks like an error in user code, treat it as fatal | ||
throw e; | ||
} | ||
return reducer.call(fallbackFn, []); |
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 think we'll want to catch the error later, but we don't need that now. Maybe we make a new formal error type.
Fairly basic - but as you know, I'm a fan of iterating in lots of steps! So, kudos for finding a way to get a lot of the value with minimal functionality. Can improve later. I might change the Generics issue, but can do that later. |
Fixes #3108.