Skip to content

Add user-facing error messages to Swift API discovery #1216

@jkmassel

Description

@jkmassel

Summary

The Kotlin wrapper has ApiDiscoveryResult.userFacingErrorMessage(url:) that maps API discovery failures to human-readable strings (offline, invalid SSL, not a WordPress site, etc.). The Swift side currently surfaces raw error.localizedDescription in the example app's LoginView, which produces unhelpful messages.

Context

Added in PR #1190 for Kotlin:

  • native/kotlin/api/kotlin/src/main/kotlin/rs/wordpress/api/kotlin/ApiDiscoveryResult.kt

We should align this approaches so they're similar. Kotlin's intermediate layer is much smaller, but we probably want to derive the user-facing error in Rust and share the approach.

Files to change

  • native/swift/Sources/wordpress-api/ — add error extension with user-facing messages
  • native/swift/Example/Example/UI/LoginView.swift — use the new messages in handleLoginError()

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions