File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -423,7 +423,9 @@ class _AsyncBoxHelper {
423423 if (message == null ) {
424424 completer.complete (newId);
425425 } else if (message is String ) {
426- completer.completeError (ObjectBoxException (message));
426+ completer.completeError (message.startsWith ('Unique constraint' )
427+ ? UniqueViolationException (message)
428+ : ObjectBoxException (message));
427429 } else {
428430 completer.completeError (ObjectBoxException (
429431 'Unknown message type (${message .runtimeType }: $message ' ));
Original file line number Diff line number Diff line change @@ -95,12 +95,14 @@ void main() {
9595 final future = box.putAsync (object);
9696 expect (
9797 future,
98- throwsA (predicate ((ObjectBoxException e) =>
98+ throwsA (predicate ((UniqueViolationException e) =>
9999 e.toString ().contains ('Unique constraint' ))));
100- // paranoia, should already have waited on the above [expect()]
100+
101101 try {
102+ // paranoia, should already have waited on the above [expect()]
102103 await future;
103104 } catch (_) {}
105+
104106 expect (object.id, isNull); // ID must remain unassigned
105107 }
106108 });
You can’t perform that action at this time.
0 commit comments