Skip to content

Commit e4b2e26

Browse files
committed
fix: throw proper exception when dog isn't currently initialized
1 parent 179a4d1 commit e4b2e26

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/dogs/lib/src/engine.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ class DogEngine with MetadataMixin {
2828
static bool get hasValidInstance => _instance != null;
2929

3030
/// Returns the current statically linked [DogEngine].
31-
static DogEngine get instance => _instance!;
31+
static DogEngine get instance {
32+
if (_instance == null) {
33+
throw DogException("No valid DogEngine instance available. Did you forget to await initialiseDogs() in your main?");
34+
}
35+
return _instance!;
36+
}
3237

3338
/// Read-only list of [DogConverter]s.
3439
final List<DogConverter> _converters = [];

0 commit comments

Comments
 (0)