mirror of https://github.com/AMT-Cheif/drift.git
Improve error handling in LazyDatabase
This commit is contained in:
parent
ab20d69846
commit
6dc198ecca
|
@ -29,11 +29,11 @@ class LazyDatabase extends QueryExecutor {
|
|||
return _openDelegate!.future;
|
||||
} else {
|
||||
final delegate = _openDelegate = Completer();
|
||||
Future.value(opener()).then((database) {
|
||||
Future.sync(opener).then((database) {
|
||||
_delegate = database;
|
||||
_delegateAvailable = true;
|
||||
delegate.complete();
|
||||
});
|
||||
}, onError: delegate.completeError);
|
||||
return delegate.future;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,4 +95,12 @@ void main() {
|
|||
|
||||
verify(inner.close());
|
||||
});
|
||||
|
||||
test('throws when opening method throws', () {
|
||||
final exception = Exception('expected');
|
||||
final lazy = LazyDatabase(() => throw exception);
|
||||
final user = _LazyQueryUserForTest();
|
||||
|
||||
expect(lazy.ensureOpen(user), throwsA(exception));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue