Some slight tweaking of main error logging and handling

This commit is contained in:
Roland Geider
2025-08-25 19:22:02 +02:00
parent e63616a403
commit 062389f8a5

View File

@@ -93,9 +93,11 @@ void main() async {
//
// NOTE: it seems this sometimes makes problems and even freezes the flutter
// process when widgets overflow, so it is disabled in dev mode.
if (kReleaseMode) {
if (!kDebugMode) {
FlutterError.onError = (FlutterErrorDetails details) {
final stack = details.stack ?? StackTrace.empty;
logger.severe('Error caught by FlutterError.onError: ${details.exception}');
FlutterError.dumpErrorToConsole(details);
// Don't show the full error dialog for network image loading errors.
@@ -110,15 +112,13 @@ void main() async {
// Catch errors that happen outside of the Flutter framework (e.g., in async operations)
PlatformDispatcher.instance.onError = (error, stack) {
if (kDebugMode) {
logger.warning('Caught error by PlatformDispatcher: $error');
logger.warning('Stack trace: $stack');
}
logger.severe('Error caught by PlatformDispatcher.instance.onError: $error');
logger.severe('Stack trace: $stack');
if (error is WgerHttpException) {
showHttpExceptionErrorDialog(error);
} else {
showGeneralErrorDialog(error, stack);
// throw error;
}
// Return true to indicate that the error has been handled.