Skip to content

Adopt generated ErrorCode#6970

Merged
AlvaroBrey merged 10 commits into
mainfrom
generated-error-codes
Jun 11, 2026
Merged

Adopt generated ErrorCode#6970
AlvaroBrey merged 10 commits into
mainfrom
generated-error-codes

Conversation

@AlvaroBrey

@AlvaroBrey AlvaroBrey commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Replace hand-written ErrorCode with the file generated by purchases-error-codes. No API changes.

Requires a small refactor to extract handwritten conformances out of ErrorCode


Note

Medium Risk
Touches the public ErrorCode API and error messaging; removing reservedRawValues and @unknown default shifts how future enum cases are handled compared to the old hand-written file.

Overview
Replaces the hand-maintained ErrorCode definition with a generated copy under Sources/Generated/, sourced from purchases-error-codes, and wires it into Xcode via a new Generated group.

SDK-specific pieces that must not be overwritten by codegen move to ErrorCode+Conformances.swift: DescribableError on ErrorCode, plus the PurchasesErrorConvertible protocol and its default helpers (previously inline in ErrorCode.swift).

The generated enum keeps the same cases, raw values, description / codeName, and CustomNSError behavior, with small copy edits (e.g. unsupported-error wording, trailing periods). Switches in the generated file are fully exhaustive and drop @unknown default and reservedRawValues; the unit test that guarded against reusing removed raw values is removed. swiftlint-baseline.json is updated so the public-enum rule still points at the new file path. Published api/*.swiftinterface files reflect a minor declaration order change around PublicError / ErrorCode with no intended API surface change.

Reviewed by Cursor Bugbot for commit 233609d. Bugbot is set up for automated code reviews on this repo. Configure here.

@AlvaroBrey AlvaroBrey force-pushed the generated-error-codes branch from 559f10f to b7312d9 Compare June 10, 2026 12:56
@AlvaroBrey AlvaroBrey marked this pull request as ready for review June 10, 2026 16:17
@AlvaroBrey AlvaroBrey requested a review from a team as a code owner June 10, 2026 16:17
Comment thread Sources/Generated/ErrorCode.swift
@AlvaroBrey AlvaroBrey requested review from ajpallares and rickvdl and removed request for a team June 10, 2026 16:25

@ajpallares ajpallares left a comment

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.

Looking good! Some comments and 1 concern about merging this before the follow-up for the macOS-specific error description

Comment thread Sources/Error Handling/ErrorCode.swift Outdated
Comment thread Sources/Generated/ErrorCode.swift
Comment thread Sources/Error Handling/ErrorCode.swift Outdated
@AlvaroBrey

Copy link
Copy Markdown
Contributor Author

Should we hold off merging this PR until the follow-up is done? To avoid shipping a version of the SDK that changes that message

Yes, I'll make that PR and see if it's worth it or if we should remove it

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e52db91. Configure here.

Comment thread Sources/Error Handling/ErrorCode.swift Outdated
Comment thread Sources/Generated/ErrorCode.swift

@rickvdl rickvdl left a comment

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.

Great work! 💪

Comment thread Sources/Generated/ErrorCode.swift
Comment thread Tests/UnitTests/Purchasing/ErrorCodeTests.swift

@ajpallares ajpallares left a comment

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.

Looks great!

@AlvaroBrey AlvaroBrey force-pushed the generated-error-codes branch from 58191a7 to 233609d Compare June 11, 2026 09:32
@AlvaroBrey AlvaroBrey merged commit b4c4dba into main Jun 11, 2026
43 checks passed
@AlvaroBrey AlvaroBrey deleted the generated-error-codes branch June 11, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants