Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

first({}) gives Bad state: No element #18

Closed
JayendraGothi opened this issue Dec 27, 2018 · 2 comments · Fixed by afnx/objectdb#1 or #25
Closed

first({}) gives Bad state: No element #18

JayendraGothi opened this issue Dec 27, 2018 · 2 comments · Fixed by afnx/objectdb#1 or #25

Comments

@JayendraGothi
Copy link

first function breaks with following message if there is no data in database:

E/flutter ( 5223): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter ( 5223): Bad state: No element
E/flutter ( 5223): #0 _ListBase&Object&ListMixin.firstWhere (dart:collection/list.dart:148:5)
E/flutter ( 5223): #1 ObjectDB._find. (package:objectdb/src/objectdb_base.dart:369:27)
E/flutter ( 5223): #2 new Future.sync (dart:async/future.dart:224:31)
E/flutter ( 5223): #3 ObjectDB._find (package:objectdb/src/objectdb_base.dart:363:19)
E/flutter ( 5223):
E/flutter ( 5223): #4 ObjectDB.first. (package:objectdb/src/objectdb_base.dart:480:50)
E/flutter ( 5223): #5 ExecutionQueue._check (package:execution_queue/execution_queue.dart:19:42)
E/flutter ( 5223):
E/flutter ( 5223): #6 ExecutionQueue._check (package:execution_queue/execution_queue.dart:21:12)
E/flutter ( 5223):
E/flutter ( 5223): #7 ExecutionQueue.add (package:execution_queue/execution_queue.dart:28:10)
E/flutter ( 5223): #8 ObjectDB.open (package:objectdb/src/objectdb_base.dart:35:33)

@marioreggiori
Copy link
Owner

What would you expect it to do?
Please use try/catch for this query.

@LaurentiuSimionescu
Copy link

This is kinda annoying. I would expect to find

{orElse: () => null}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants