Callback returning “Void” prints unhandled error exception

The “void” return value is a null object in Dart, which is checked to be non-null. The check throws an exception, leading to:

==================== UNHANDLED EXCEPTION FROM FFI CALLBACK ====================
 ** Native callbacks should not throw exceptions because they cannot be
    propagated into native code. **
EXCEPTION: NoSuchMethodError: The method 'FfiCallback' was called on null.
Receiver: null
Tried calling: FfiCallback()
#0      FfiCallback (dart:ffi)
#1      FfiTrampoline (dart:ffi)
#2      Test.run (file:///usr/local/google/home/sjindel/src/dart-sdk/sdk/tests/ffi/function_callbacks_test.dart:38:32)
#3      main.<anonymous closure> (file:///usr/local/google/home/sjindel/src/dart-sdk/sdk/tests/ffi/function_callbacks_test.dart:196:30)
#4      List.forEach (dart:core-patch/growable_array.dart:278:8)
#5      main (file:///usr/local/google/home/sjindel/src/dart-sdk/sdk/tests/ffi/function_callbacks_test.dart:196:13)
<asynchronous suspension>
#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

Author: Fantashit

1 thought on “Callback returning “Void” prints unhandled error exception

Comments are closed.