From 328abfd5d31aa73a732eef6885ac0e26819c7d17 Mon Sep 17 00:00:00 2001 From: Mica White Date: Sat, 24 Jan 2026 13:14:55 -0500 Subject: Add logging for debugging errors --- lib/jotai.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/jotai.dart') diff --git a/lib/jotai.dart b/lib/jotai.dart index 5524e6a..dc1b165 100644 --- a/lib/jotai.dart +++ b/lib/jotai.dart @@ -41,7 +41,15 @@ Future fromString( .then( // Going through all of these sounds like it's slower than necessary, // but it's very simple, and most of the options lists are very small. - (value) => options.firstWhere((option) => value == toString(option)), + (value) { + try { + return options.firstWhere((option) => value == toString(option)); + } catch (error, stack) { + logObservable.value = logObservable.value + ..add('While loading $key:\n$error\n$stack'); + rethrow; + } + }, ); } @@ -82,6 +90,8 @@ final locationAccuracyObservable = observablePreference( LocationAccuracy.values, ); +final logObservable = Observable([]); + class Observable { T _value; int _nextId = 0; -- cgit v1.3.1