From bf902d79ee2d5bfbe99ab7ed4c4c68e92f8c3798 Mon Sep 17 00:00:00 2001 From: dab246 Date: Thu, 1 Jun 2023 13:52:32 +0700 Subject: [PATCH] TF-1813 Add log `stackTrace` in ExceptionThrower (cherry picked from commit a1634ad2553fb331603738620b416a5a7dda66a8) --- .../data/datasource_impl/cache_fcm_datasource_impl.dart | 4 +--- lib/main/exceptions/cache_exception_thrower.dart | 4 +++- lib/main/exceptions/exception_thrower.dart | 2 +- lib/main/exceptions/remote_exception_thrower.dart | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart b/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart index 76668dca8..4ba5d92ca 100644 --- a/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart +++ b/lib/features/push_notification/data/datasource_impl/cache_fcm_datasource_impl.dart @@ -51,9 +51,7 @@ class CacheFCMDatasourceImpl extends FCMDatasource { Future storeSubscription(FCMSubscriptionCache fcmSubscriptionCache) { return Future.sync(() async { return await _firebaseCacheManager.storeSubscription(fcmSubscriptionCache); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); + }).catchError(_exceptionThrower.throwException); } @override diff --git a/lib/main/exceptions/cache_exception_thrower.dart b/lib/main/exceptions/cache_exception_thrower.dart index 852bdca45..488a4742a 100644 --- a/lib/main/exceptions/cache_exception_thrower.dart +++ b/lib/main/exceptions/cache_exception_thrower.dart @@ -1,9 +1,11 @@ +import 'package:core/utils/app_logger.dart'; import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; class CacheExceptionThrower extends ExceptionThrower { @override - throwException(dynamic error) { + throwException(dynamic error, dynamic stackTrace) { + logError('CacheExceptionThrower::throwException():error: $error | stackTrace: $stackTrace'); throw error; } } \ No newline at end of file diff --git a/lib/main/exceptions/exception_thrower.dart b/lib/main/exceptions/exception_thrower.dart index 9c21dc60c..175b85a66 100644 --- a/lib/main/exceptions/exception_thrower.dart +++ b/lib/main/exceptions/exception_thrower.dart @@ -1,4 +1,4 @@ abstract class ExceptionThrower { - throwException(dynamic error); + throwException(dynamic error, dynamic stackTrace); } diff --git a/lib/main/exceptions/remote_exception_thrower.dart b/lib/main/exceptions/remote_exception_thrower.dart index cd9b3a8df..f275ad9b3 100644 --- a/lib/main/exceptions/remote_exception_thrower.dart +++ b/lib/main/exceptions/remote_exception_thrower.dart @@ -14,8 +14,8 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart'; class RemoteExceptionThrower extends ExceptionThrower { @override - throwException(dynamic error) { - logError('RemoteExceptionThrower::throwException():error: $error'); + throwException(dynamic error, dynamic stackTrace) { + logError('RemoteExceptionThrower::throwException():error: $error | stackTrace: $stackTrace'); final networkConnectionController = getBinding(); if (networkConnectionController?.isNetworkConnectionAvailable() == false) { logError('RemoteExceptionThrower::throwException():isNetworkConnectionAvailable');