File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,11 @@ ObjectBoxC? _tryObjectBoxLibProcess() {
2222 _lib = DynamicLibrary .process ();
2323 obxc = ObjectBoxC (_lib! );
2424 _isSupportedVersion (obxc); // may throw in case symbols are not found
25+ return obxc;
2526 } catch (_) {
2627 // ignore errors (i.e. symbol not found)
28+ return null ;
2729 }
28- return null ;
2930}
3031
3132ObjectBoxC ? _tryObjectBoxLibFile () {
Original file line number Diff line number Diff line change @@ -419,16 +419,20 @@ class _AsyncBoxHelper {
419419 }
420420
421421 port.listen ((dynamic message) {
422- // Null is sent if the put was successful (there is no error, thus NULL)
423- if (message == null ) {
424- completer.complete (newId);
425- } else if (message is String ) {
426- completer.completeError (message.startsWith ('Unique constraint' )
427- ? UniqueViolationException (message)
428- : ObjectBoxException (message));
429- } else {
430- completer.completeError (ObjectBoxException (
431- 'Unknown message type (${message .runtimeType }: $message ' ));
422+ if (! completer.isCompleted) {
423+ // Null is sent if the put was successful (there is no error, thus NULL)
424+ if (message == null ) {
425+ completer.complete (newId);
426+ } else if (message is String ) {
427+ print ('Received string error message: $message ' );
428+ completer.completeError (message.startsWith ('Unique constraint' )
429+ ? UniqueViolationException (message)
430+ : ObjectBoxException (message));
431+ } else {
432+ print ('Received other error message: $message ' );
433+ completer.completeError (ObjectBoxException (
434+ 'Unknown message type (${message .runtimeType }: $message ' ));
435+ }
432436 }
433437 port.close ();
434438 });
You can’t perform that action at this time.
0 commit comments