-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Introduce Result\try_catch shortcut #403
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 4294599427
💛 - Coveralls |
veewee
force-pushed
the
result-try-catch
branch
from
February 28, 2023 13:59
230d389
to
eb7374e
Compare
veewee
added
Priority: Medium
This issue may be useful, and needs some attention.
Status: Completed
Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness
Status: Review Needed
The issue has a PR attached to it which needs to be reviewed.
Type: Enhancement
Most issues will probably ask for additions or changes.
labels
Feb 28, 2023
veewee
force-pushed
the
result-try-catch
branch
from
February 28, 2023 15:27
eb7374e
to
f6c0c09
Compare
azjezz
approved these changes
Feb 28, 2023
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.
looks awesome!
renovate bot
referenced
this pull request
in ben-challis/sql-migrations
Mar 18, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [amphp/file](https://togithub.com/amphp/file) | require | patch | `3.0.0-beta.6` -> `3.0.0` | | [azjezz/psl](https://togithub.com/azjezz/psl) | require | minor | `2.4.1` -> `2.5.0` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>amphp/file</summary> ### [`v3.0.0`](https://togithub.com/amphp/file/releases/tag/v3.0.0): 3.0.0 [Compare Source](https://togithub.com/amphp/file/compare/v3.0.0-beta.6...v3.0.0) Stable release compatible with AMPHP v3 and fibers! 🎉 As with other libraries compatible with AMPHP v3, most cases of parameters or returns of `Promise<ResolutionType>` have been replaced with `ResolutionType`. - Renamed `BlockingDriver` to `BlockingFilesystemDriver` - Renamed `EioDriver` to `EioFilesystemDriver` - Renamed `ParallelDriver` to `ParallelFilesystemDriver` - Renamed `StatusCachingDriver` to `StatusCachingFilesystemDriver` - Renamed `UvDriver` to `UvFilesystemDriver` - Renamed `Amp\File\Sync\AsyncFileMutex` to `Amp\File\FileMutex` - Added `?Cancellation` as first parameter of `File::read()` - Added `File::isSeekable()` - Removed `File::SEEK_SET`, `File::SEEK_CUR`, and `File::SEEK_END` - Added `Amp\File\Whence` for seeking instead </details> <details> <summary>azjezz/psl</summary> ### [`v2.5.0`](https://togithub.com/azjezz/psl/releases/tag/2.5.0): Lenalee - 2.5.0 [Compare Source](https://togithub.com/azjezz/psl/compare/2.4.1...2.5.0) #### What's Changed ##### Features - Introduce Result\try_catch shortcut by [@​veewee](https://togithub.com/veewee) in [https://github.com/azjezz/psl/pull/403](https://togithub.com/azjezz/psl/pull/403) ##### Fixes - Imrovements on file creation during write modes by [@​veewee](https://togithub.com/veewee) in [https://github.com/azjezz/psl/pull/401](https://togithub.com/azjezz/psl/pull/401) **Full Changelog**: azjezz/psl@2.4.1...2.5.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ben-challis/sql-migrations). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTAuMiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Priority: Medium
This issue may be useful, and needs some attention.
Status: Completed
Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness
Status: Review Needed
The issue has a PR attached to it which needs to be reviewed.
Type: Enhancement
Most issues will probably ask for additions or changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inspired on ramda's tryCatch function:
https://ramdajs.com/docs/#tryCatch
It can be seen as a shortcut for dealing with code that you know might error, for which you want to continue the flow with e.g. a default or calculated default value.
For example:
I decided not to go the
Fun
way as it is in ramda, since it would require another dynamic psalm plugin.Instead, you could make it composable yourself like this:
It also works fine with
Option\from_nullable()
as you can from the examples above.❗ Note: I inlined the
PromiseInterface
methods into theResultInterface
and made sure the return type for them isResultInterface
. Otherwise psalm thinksResultInterface::catch()
(and others) returns aPromiseInterface
instead of aResultInterface
.