From e6094fb62391d565545ddea45f10945a312b4e57 Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 12 Jul 2024 18:59:52 +0700 Subject: [PATCH] TF-2928 Handle connection error exception --- lib/features/base/base_controller.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/features/base/base_controller.dart b/lib/features/base/base_controller.dart index 0c670ae15..15c0166f1 100644 --- a/lib/features/base/base_controller.dart +++ b/lib/features/base/base_controller.dart @@ -188,11 +188,7 @@ abstract class BaseController extends GetxController void handleUrgentExceptionOnMobile({Failure? failure, Exception? exception}) { logError('$runtimeType::handleUrgentExceptionOnMobile():Failure: $failure | Exception: $exception'); if (exception is ConnectionError) { - if (currentOverlayContext != null && currentContext != null) { - appToast.showToastErrorMessage( - currentOverlayContext!, - AppLocalizations.of(currentContext!).connectionError); - } + _handleConnectionErrorException(); } else if (exception is BadCredentialsException) { _executeBeforeUnloadAndLogOut(); } @@ -213,11 +209,7 @@ abstract class BaseController extends GetxController infinityToast: true,); } } else if (exception is ConnectionError) { - if (currentOverlayContext != null && currentContext != null) { - appToast.showToastErrorMessage( - currentOverlayContext!, - AppLocalizations.of(currentContext!).connectionError); - } + _handleConnectionErrorException(); } else if (exception is BadCredentialsException) { _executeBeforeUnloadAndLogOut(); } @@ -228,6 +220,14 @@ abstract class BaseController extends GetxController clearDataAndGoToLoginPage(); } + void _handleConnectionErrorException() { + if (currentOverlayContext != null && currentContext != null) { + appToast.showToastErrorMessage( + currentOverlayContext!, + AppLocalizations.of(currentContext!).connectionError); + } + } + void handleFailureViewState(Failure failure) async { logError('$runtimeType::handleFailureViewState():Failure = $failure'); if (failure is LogoutOidcFailure) {