2025-01-21 14:24:31 +03:00
|
|
|
part of 'app_runner.dart';
|
|
|
|
|
|
|
|
|
|
/// Метод инициализации обработчиков ошибок
|
|
|
|
|
void _initErrorHandlers(IDebugService debugService) {
|
|
|
|
|
// Обработка ошибок в приложении
|
|
|
|
|
FlutterError.onError = (details) {
|
|
|
|
|
_showErrorScreen();
|
2025-02-04 10:18:41 +03:00
|
|
|
debugService.logError(
|
|
|
|
|
() => 'FlutterError.onError: ${details.exceptionAsString()}',
|
|
|
|
|
error: details.exception,
|
|
|
|
|
stackTrace: details.stack,
|
|
|
|
|
);
|
2025-01-21 14:24:31 +03:00
|
|
|
};
|
|
|
|
|
// Обработка асинхронных ошибок в приложении
|
|
|
|
|
PlatformDispatcher.instance.onError = (error, stack) {
|
|
|
|
|
_showErrorScreen();
|
2025-02-04 10:18:41 +03:00
|
|
|
debugService.logError(
|
|
|
|
|
() => 'PlatformDispatcher.instance.onError',
|
|
|
|
|
error: error,
|
|
|
|
|
stackTrace: stack,
|
|
|
|
|
);
|
2025-01-21 14:24:31 +03:00
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-02-04 10:18:41 +03:00
|
|
|
|
2025-01-21 14:24:31 +03:00
|
|
|
/// Метод для показа экрана ошибки
|
|
|
|
|
void _showErrorScreen() {
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
AppRouter.rootNavigatorKey.currentState?.push(
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (_) => const ErrorScreen(),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|