tdvCheckException function Null safety

void tdvCheckException(
  1. Pointer<Pointer<Void>> exception,
  2. DynamicLibrary dll_handle
)

Implementation

void tdvCheckException(Pointer<Pointer<Void>> exception, DynamicLibrary dll_handle) {
  if (exception.value.address != nullptr.address) {
    final check_exception_code = dll_handle.lookupFunction<_exceptionCode_c, _exceptionCode_dart>("TDVException_" + 'getErrorCode');

    final check_exception_message = dll_handle.lookupFunction<_exceptionWhat, _exceptionWhat>("TDVException_" + 'getMessage');

    final res_ex = check_exception_code(exception.value);
    developer.log("Check context ex " + res_ex.toRadixString(16), name: 'my.app.category');

    final res_ex_content = check_exception_message(exception.value).toDartString();
    developer.log("Check context ex2 " + res_ex_content, name: 'my.app.category');
    if (res_ex != 0) {
      throw ("Error 0x$res_ex. Text: $res_ex_content");
    }
  }

  if (exception.address != nullptr.address) malloc.free(exception);
}