expectAimuxError function
Decode the aimux_error_t * e returned by a call that can fail in
AiMuxError ([AiMuxError] in aimux-ffi.h). NULL → returns (success).
Codes 1..17 become AimuxException; 200..206 become StateError.
The returned error is always freed.
Implementation
void expectAimuxError(Pointer<Void> e, String context) {
if (e == nullptr) return;
final Object failure;
try {
final code = _errorCode(e);
failure = _isFfiCode(code)
? _ffiError(e, context)
: AimuxException._decode(e, context);
} finally {
_errorFree(e);
}
throw failure;
}