mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Catch uncaught async errors and surface response-shape failures
Wrap main in runZonedGuarded and install FlutterError.onError / PlatformDispatcher.onError so background async failures get logged instead of dying silently. Guard PrefUtil.init so a SharedPreferences platform error no longer aborts startup. Recognize TypeError and FormatException in dioErrorToUserMessage to give a clearer message when the backend returns an unexpected JSON shape or bad timestamp. Wrap Settings._save in try/catch so prefs write failures show a snackbar instead of leaving the Save button silently dead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e70676a193
commit
140ebab035
@@ -59,6 +59,10 @@ LogInterceptor _buildLogInterceptor() => LogInterceptor(
|
||||
);
|
||||
|
||||
String dioErrorToUserMessage(Object error) {
|
||||
if (error is TypeError || error is FormatException) {
|
||||
debugPrint('Backend response shape error: $error');
|
||||
return 'Unexpected response shape from backend.';
|
||||
}
|
||||
if (error is! DioException) {
|
||||
debugPrint('Non-Dio error from backend call: $error');
|
||||
return 'Unexpected error.';
|
||||
|
||||
Reference in New Issue
Block a user