PeripheralCodecException
Sealed root of failures raised by readAs / writeAs / observeAs that originate inside the codec layer (as opposed to the underlying BLE op).
Match exhaustively when distinguishing codec failures from arbitrary BLE errors that may also surface via Result.failure:
when (val cause = result.exceptionOrNull()) {
is PeripheralCodecException -> when (cause) {
is CharacteristicNotFoundException -> ...
is PeripheralNotReadyException -> ...
is DecodeFailureException -> ...
}
else -> ... // BLE error, cancellation, etc.
}Content copied to clipboard
Adding a subclass is a source-breaking change for callers using when as an expression that exhaustively matches the sealed subclasses without an else branch. Callers matching on the sealed root, or with an else branch, are unaffected at compile time.