Skip to content

Commit b571130

Browse files
author
Ivan Dlugos
committed
handle box.remove() not-found without catching exceptions
1 parent fa51c1f commit b571130

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/src/box.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,9 @@ class Box<T> {
228228
}
229229

230230
bool remove(int id) {
231-
try {
232-
checkObx(bindings.obx_box_remove(_cBox, id));
233-
} on ObjectBoxException catch (ex) {
234-
if (ex.msg == "code 404") {
235-
return false;
236-
}
237-
rethrow;
238-
}
231+
final err = bindings.obx_box_remove(_cBox, id);
232+
if (err == OBXError.OBX_NOT_FOUND) return false;
233+
checkObx(err); // throws on other errors
239234
return true;
240235
}
241236

0 commit comments

Comments
 (0)