Error handling
connect() and disconnect() throw a sealed WiDASException with stable types, so you can
branch in code. Every case carries a code: a stable string that is identical in the iOS SDK,
so a team shipping on both platforms logs, reports and translates off one vocabulary. Branch on the
Kotlin type; key your telemetry and your copy off code.
sealed class WiDASException(val code: String, ...) : Exception() {
data object AttestationUnavailable : WiDASException("attestationUnavailable", ...)
data object AttestationRejected : WiDASException("attestationRejected", ...)
data object IssuanceRejected : WiDASException("issuanceRejected", ...)
data object ServiceUnavailable : WiDASException("serviceUnavailable", ...)
data object EntitlementMissing : WiDASException("entitlementMissing", ...)
data object PasspointInstallFailed : WiDASException("passpointInstallFailed", ...)
data object Revoked : WiDASException("revoked", ...)
data object Network : WiDASException("network", ...)
data object Cancelled : WiDASException("cancelled", ...)
data class Internal(private val underlying: Throwable) : WiDASException("internal", ..., underlying)
}
Renaming a code is a breaking change, so treat the strings as part of the API. Each code is its type
name with a lower-case first letter, so you rarely need to look one up. Internal keeps the original
throwable private and passes it on as the exception's standard cause, so read it from there.
The types
| Type | Meaning | What to do |
|---|---|---|
AttestationUnavailable | (Play Integrity only) This device or app can never attest — no Play Services or Play Store, an outdated one, an app-identity mismatch, or a misconfigured cloud project number. | Degrade the UI. Don't loop on it. |
AttestationRejected | (Play Integrity only) Wi-DAS rejected the attestation. | Check the app-signing cert SHA-256 and package name are registered against your clientId. See the Play App Signing trap. 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. Not a refusal on the 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 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 Wi-Fi permissions and that the device supports Passpoint suggestions. |
Revoked | The certificate is revoked. Reserved — on Android, revocation reaches you through status() as REVOKED rather than as a throw. | Call disconnect() to clean up, then connect() for a fresh certificate. |
Network | A transport failure, an undecodable response, your Broker being unreachable, or Google's Play Integrity service being unreachable or throttling. | Retry once connectivity is back. |
Cancelled | Carried for parity with iOS. Never thrown on Android — see Cancellation. | Nothing. |
Internal | An unexpected local failure: device key generation, CSR construction, storage. cause retains the original throwable. Also what an unexpected exception from your Broker becomes. | Don't retry. Report it, with cause. |
Cancelled is the only case the two SDKs treat differently, and it's deliberate — see
Cancellation. Everything else, ServiceUnavailable and Internal included, matches
case for case.
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, attestation or key generation — you never burn a freshly-issued certificate on an install that could never have worked:
- A blank or unconfigured
clientId. Whitespace counts, since that's what an unsubstituted build placeholder collapses to. android.permission.CHANGE_WIFI_STATEnot granted. The SDK declares it, but a host app can strip it through manifest-merger rules, and without it a successful issuance could only ever be followed by a failed install.
The single code deliberately doesn't distinguish them; the SDK logs which one it was, so check Logcat. 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.
Cancellation
kotlinx.coroutines.CancellationException propagates intact out of connect(), status() and
disconnect(). The SDK never converts it into WiDASException.Cancelled, because typing it would
break structured concurrency for you. The cancelled code exists purely so the two SDKs publish one
vocabulary: on iOS, URLError.cancelled is a URLSession outcome that would otherwise look
indistinguishable from a transport fault, so iOS does throw it.
status() degrades rather than throws
Any lookup failure inside status() falls back to the locally-stored validity window. Two things it
doesn't absorb: cancellation propagates as above, and a broken local state store surfaces as
Internal — without a serial there's nothing left to report on. So it's safe to call from a render
path, but it isn't a method that can never throw.
debugInfo() reports no types
debugInfo() never throws and never reports a code. It returns the whole
payload or null, and null 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. Coroutine cancellation still propagates as usual.
connect() remains where you get a code.
Where the types come from
The API reports failures as RFC 9457 problem+json, and the SDK maps each one to a typed exception.
You only ever see the sealed WiDASException: the facade wraps the whole flow, so even an unforeseen
platform exception arrives as Internal rather than escaping raw.
| Server reports | → Type |
|---|---|
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 |
|---|---|
BrokerRefusedException(problemTitle) | The WiDASException that title maps to; IssuanceRejected if it's unrecognised or missing |
BrokerUnreachableException | Network |
A bare IOException | Network |
CancellationException | Passes through untouched |
| Anything else | Internal |
A few refusals only happen on the brokered route:
Problem title | → Type | 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 Play Integrity.
Branching example
try {
widas.connect(user = userId, requestedValidity = "P365D")
} catch (e: WiDASException) {
when (e) {
WiDASException.Network,
WiDASException.ServiceUnavailable -> scheduleRetry() // transient
WiDASException.AttestationRejected,
WiDASException.EntitlementMissing -> reportConfigProblem() // registration issue
WiDASException.Revoked -> {
widas.disconnect() // clear the dead profile
showRevokedMessage()
}
WiDASException.AttestationUnavailable -> showUnsupportedDevice() // Play Integrity route only
is WiDASException.Internal -> report(e.code, e.cause) // never retry
else -> showGenericError()
}
}
// CancellationException is not a WiDASException and passes straight through. That's intentional.
Network and ServiceUnavailable are worth a retry with backoff. AttestationRejected,
EntitlementMissing, and IssuanceRejected point at a configuration or registration problem, so
retrying without a fix just fails again. Troubleshooting walks through
the fixes.