Implementation
void main() async {
// Logs sync errors to the logs page
FlutterError.onError = (FlutterErrorDetails details) {
if (kDebugMode) {
FlutterError.presentError(details); // do the regular error behavior
} else {
logError(details.exception, details.stack);
}
};
// Logs async errors to the logs page
runZonedGuarded(
() => runApp(RoverControlDashboard()),
(error, stackTrace) async {
if (error is SocketException && networkErrors.contains(error.osError!.errorCode)) {
models.home.setMessage(severity: Severity.critical, text: "Network error, restart by clicking the network icon");
} else {
if (kDebugMode) {
Error.throwWithStackTrace(error, stackTrace); // do the regular error behavior
} else {
logError(error, stackTrace);
}
}
}
);
}