Add ErrorResult.get(mapError:) and expectSuccess(orError:mapError:) - #35
Merged
Conversation
get(mapError:) replaces the switch that PAR and token-endpoint callers in oauth4swift hand-roll. expectSuccess(orError:mapError:) covers endpoints with no success body - lifted from oauth4swift, where token revocation needs it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
germ-mark
force-pushed
the
mark/expect-success-or-error
branch
from
July 28, 2026 20:05
7985149 to
cf1ca2d
Compare
🦋 Changeset detectedLatest commit: cf1ca2d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Merged
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #34 — review that one first; this diff is only the last commit.
Lifts
successOrThrowout of oauth4swift, per the review on germ-network/oauth4swift#51, and adds theErrorResultcounterpart the existing callers were hand-rolling.ErrorResult.get(mapError:)— returns the result or throws a mapped error. Both existing consumers (PAR atOAuth+Components.swift:23, token endpoint at:164) already write exactly this switch by hand.expectSuccess(orError:mapError:)— for endpoints with no success body. Kept separate fromgetrather than folded into it, since going throughsuccesswould mean passingData.selfas a phantom result type.Renamed from
successOrThrowon the way up: in this structexpect…already means "throws on mismatch" andsuccess…means "returns anErrorResult", and this throws. The rename also means it can't collide with the internal copy that stays on oauth4swift#51 until that repo picks the new version up.getdeliberately echoesResult.get()— same unwrap-or-throw job — though Swift's takes no argument and throws the contained error rather than mapping one. The argument label keeps them distinguishable at the call site, butunwrap(mapError:)is a reasonable override if it reads wrong.Both are additive with no call sites until oauth4swift adopts them, so they can share a release with #34 — only #34 can move downstream behavior.
Test notes
swift testgreen, 25 tests across 7 suites.🤖 Generated with Claude Code