Error handling
connect() and disconnect() throw a typed WiDASError with stable cases, so you can branch in
code and say something useful to the user. status() never throws, and
debugInfo() throws only cancelled.
Every case carries a code: a stable string that is identical in the Android SDK, so a team
shipping on both platforms logs, reports and translates off one vocabulary. Branch on the Swift case;
key your telemetry and your copy off code. Each case also carries an errorDescription aimed at
you reading a log, not at your end user — the wording your users see stays yours.
public enum WiDASError: LocalizedError, Equatable {
case attestationUnavailable
case attestationRejected
case issuanceRejected
case serviceUnavailable
case entitlementMissing
case passpointInstallFailed
case revoked
case network
case cancelled
case internalError(underlying: Error) // code is "internal"
public var code: String { ... }
}
Renaming a code is a breaking change, so treat the strings as part of the API. Two notes on the
shape: the case is internalError because internal is a Swift keyword, and Equatable compares by
code, so two internalErrors are equal whatever their payload — read the cause off the associated
value when you need it.
Each code is simply the case name — the sole exception being internalError, whose code is
internal.
The cases
| Case | Meaning | What to do |
|---|---|---|
attestationUnavailable | (App Attest only) App Attest can't run here (Simulator, unsupported, or de-attested), or it failed locally so no attestation could be produced. | Degrade the UI. Don't loop on it. Test on a device. |
attestationRejected | (App Attest only) Wi-DAS rejected the attestation. | Check the app is registered (Team ID + bundle ID) against your clientId. Not worth retrying as-is. |
issuanceRejected | The request reached the issuer and was refused on its merits: an invalid CSR, validity or challenge, or a user whose CN would exceed 64 characters. Also the fallback for a response the SDK doesn't recognise, including a refusal your Broker passed on without its title. | Fix the integration; check requestedValidity, the user you pass, and that your Broker passes the problem title through unchanged. Don't retry unchanged. |
serviceUnavailable | A server-side fault — the issuing CA or the RADIUS server-trust material is unreachable. The request wasn't refused on its merits. | Retry with backoff. |
entitlementMissing | No valid entitlement to onboard. Either caught locally before any network call, or reported by the server, including when Wi-DAS doesn't entitle your Broker to issue for this clientId. See below. | Fix the configuration or provisioning, or ask Wi-DAS to check the Client registry. Don't retry as-is. |
passpointInstallFailed | The Passpoint profile wouldn't install or remove. | Retry once; if it persists, check the Hotspot Configuration entitlement and your Keychain access group. |
revoked | The certificate is revoked. Reserved — the issuer doesn't emit it today; revocation normally reaches you through status() as .revoked. | Call disconnect() to clean up, then connect() for a fresh certificate. |
network | A transport or connectivity failure, including your Broker or Apple's attestation service being unreachable. | Retry once connectivity is back. |
cancelled | The enclosing Task or the request was cancelled. | Nothing — the user walked away. Never surface it as an error. |
internalError(underlying:) | An unexpected local failure: device key generation, CSR construction, or anything else that would otherwise escape raw. underlying retains the original error. Also what an unexpected error from your Broker becomes. | Don't retry. Report it, with errorDescription. |
The Android SDK carries cancelled for parity but never throws it: Kotlin structured concurrency
requires CancellationException to propagate intact. iOS does throw it, because URLError.cancelled
is a URLSession outcome that would otherwise look indistinguishable from a transport fault. That's
the only difference between the two case sets.
entitlementMissing is caught early
This is the expected number-one integration problem, so the causes you can fix in your own app are detected before any network call, key generation or attestation — you never burn a freshly-issued certificate on a profile install that could never have worked:
- A blank or unconfigured
clientId. Whitespace counts, since that's what an unsubstituted build placeholder collapses to. - A missing entitlement, read from your app's own
embedded.mobileprovision:com.apple.developer.networking.HotspotConfiguration— installing the Passpoint profilecom.apple.developer.devicecheck.appattest-environment— App Attest, checked only if you issue through it
The single code deliberately doesn't distinguish them; the SDK logs which one it was to the
com.widas.sdk subsystem, so check the Console. The entitlement half fails open — a build
shipping no provisioning profile passes the check — so it can only ever turn a late, confusing
failure into an early, specific one.
The server stays authoritative for what only it knows — an unknown Client, or a Client or parent Partner that's been disabled, or a Broker that isn't entitled to issue for your Client — and reports the same code.
debugInfo() reports no cases
debugInfo() never reports a code. It returns the whole payload or nil,
and nil covers both the expected non-DevMode case and any failure to read the configuration —
deliberately undistinguished, because a failed read can't tell the SDK whether DevMode was on, so a
typed reason there would be a guess. Cancellation is the exception: an abandoned call throws
cancelled rather than reading as "not in DevMode". connect() remains where you get a code.
Where the cases come from
The API reports failures as RFC 9457 problem+json, and the SDK maps each one to the matching
WiDASError. Nothing raw ever reaches you — no DCError, URLError, Security-framework or
swift-certificates error — because every seam types its failures, with internalError reserved for
local key and CSR faults.
| Server reports | → Case |
|---|---|
attestationUnavailable | .attestationUnavailable |
attestationRejected | .attestationRejected |
partnerUnknown, partnerDisabled | .entitlementMissing |
certificateRevoked | .revoked (reserved; the issuer doesn't send it today) |
caUnavailable, serverTrustUnavailable | .serviceUnavailable |
validityInvalid, challengeInvalid, csrInvalid, subjectInvalid | .issuanceRejected |
| anything unrecognised | .issuanceRejected |
On the brokered route the answer arrives through your Broker instead, which is why your adapter must
pass the problem title through exactly as it arrived. Your Broker reports failures like this:
What your Broker throws | What your app sees |
|---|---|
BrokerError.refused(problemTitle:) | The WiDASError that title maps to; issuanceRejected if it's unrecognised or missing |
BrokerError.unreachable(underlying:) | network |
A URLError | network, or cancelled if the request was cancelled |
| Anything else | internalError |
A few refusals only happen on the brokered route:
Problem title | → Case | What it means |
|---|---|---|
brokerNotAuthorised | .entitlementMissing | Your Broker isn't registered to issue for this clientId, or it's been disabled. |
issuanceTimedOut, issuanceInProgress, idempotencyUnavailable | .serviceUnavailable | Temporary. Your Broker should retry, using the key the refusals table gives for each. |
idempotencyKeyMissing, idempotencyKeyTooLong, idempotencyKeyReused | .issuanceRejected | Your Broker built its Idempotency-Key wrongly. The fix is in the Broker. |
On the brokered route you won't see attestationUnavailable or attestationRejected, because the SDK
never runs App Attest.
Branching example
do {
try await widas.connect(user: userID, requestedValidity: "P365D")
} catch WiDASError.cancelled {
// the user walked away — not an error
} catch WiDASError.serviceUnavailable, WiDASError.network {
scheduleRetry() // transient — back off and try again
} catch WiDASError.attestationRejected, WiDASError.entitlementMissing {
reportConfigurationProblem() // registration / entitlement — not user-fixable
} catch WiDASError.revoked {
try? await widas.disconnect() // clear the dead profile
showRevokedMessage()
} catch WiDASError.attestationUnavailable {
showUnsupportedDevice() // App Attest route only
} catch let error as WiDASError {
report(error.code, error.errorDescription)
} catch {
showGenericError()
}
serviceUnavailable and network are worth a retry. attestationRejected, entitlementMissing,
and issuanceRejected point at a configuration or registration problem, so retrying without a fix
just fails again. Troubleshooting walks through the fixes.