expectFfiError function

void expectFfiError(
  1. Pointer<Void> e,
  2. String context
)

Same for calls that only expose C ABI failures ([C ABI]): message only → invariant StateError.

Implementation

void expectFfiError(Pointer<Void> e, String context) {
  if (e == nullptr) return;
  final Object failure;
  try {
    final code = _errorCode(e);
    failure = _isFfiCode(code)
        ? _ffiError(e, context)
        : StateError('aimux ffi: $context: expected C ABI failure code, got $code');
  } finally {
    _errorFree(e);
  }
  throw failure;
}