Skip to content

Prototype: replace WpErrorCode fallback with WpErrorCodeValue record#1365

Draft
oguzkocer wants to merge 2 commits into
trunkfrom
prototype/enum-parsed-value
Draft

Prototype: replace WpErrorCode fallback with WpErrorCodeValue record#1365
oguzkocer wants to merge 2 commits into
trunkfrom
prototype/enum-parsed-value

Conversation

@oguzkocer
Copy link
Copy Markdown
Contributor

Description

Replace the CustomError(String) fallback variant in WpErrorCode with a new WpErrorCodeValue record that separates the parsed enum from the raw API string:

  • value: Option<WpErrorCode>Some for known variants, None for unknown
  • raw: String — always the original string from the API

This makes adding new WpErrorCode variants forward-compatible: client code checking the raw string continues to work after a variant is promoted, and the enum stays a real enum with full match support.

Also changes WpErrorCode from uniffi::Error to uniffi::Enum since it was never returned as an error directly — always embedded as a field.

Helper methods on WpErrorCodeValue: is_code(), is_raw(), is_any_code().

Changelog

  • I've added an entry to CHANGELOG.md under ## [Unreleased], using the Keep a Changelog categories (Added, Changed, Deprecated, Removed, Fixed, Security). Prefix breaking changes with **BREAKING:**.

Replace the `CustomError(String)` fallback variant in `WpErrorCode` with
a new `WpErrorCodeValue` record that separates the parsed enum from the
raw API string:

- `value: Option<WpErrorCode>` — `Some` for known variants, `None` for unknown
- `raw: String` — always the original string from the API

This makes adding new `WpErrorCode` variants forward-compatible: client
code checking the `raw` string continues to work after a variant is
promoted, and the enum stays a real enum with full match support.

Also changes `WpErrorCode` from `uniffi::Error` to `uniffi::Enum` since
it was never returned as an error directly — always embedded as a field.

Helper methods on `WpErrorCodeValue`: `is_code()`, `is_raw()`, `is_any_code()`.
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented May 30, 2026

⚠️ CHANGELOG.md was not updated in this PR.

Every PR should add an entry under the ## [Unreleased] section of CHANGELOG.md describing the change for our users. The format follows Keep a Changelog 1.0.0 — use one of:

  • ### Added — for new features
  • ### Changed — for changes in existing functionality (prefix **BREAKING:** if breaking)
  • ### Deprecated — for soon-to-be-removed features
  • ### Removed — for now-removed features
  • ### Fixed — for any bug fixes
  • ### Security — for vulnerability fixes

If the change genuinely has no user-visible impact (e.g. CI-only tweaks, internal refactors), add a short entry under ### Changed noting that.

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented May 30, 2026

XCFramework Build

This PR's XCFramework is available for testing. Add to your Package.swift:

.package(url: "https://github.com/automattic/wordpress-rs", branch: "pr-build/1365")

Built from c88cca7

`retrieveWithEditContext` expects a `PostType`, not a raw string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants