From 3e39f59f200af0301538b4c2d8b0fce9f5f6230d Mon Sep 17 00:00:00 2001 From: "Dat H. Pham" Date: Mon, 9 Mar 2026 09:02:55 +0700 Subject: [PATCH] Fixup Constant some token exception --- core/lib/utils/sentry/sentry_config.dart | 2 +- .../domain/exceptions/fcm_exception.dart | 24 +++++++++---------- lib/main/exceptions/cache_exception.dart | 2 +- lib/main/exceptions/remote_exception.dart | 10 ++++---- .../lib/exceptions/token_oidc_exceptions.dart | 8 +++---- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/core/lib/utils/sentry/sentry_config.dart b/core/lib/utils/sentry/sentry_config.dart index 72c55e990..4bf6f0854 100644 --- a/core/lib/utils/sentry/sentry_config.dart +++ b/core/lib/utils/sentry/sentry_config.dart @@ -71,7 +71,7 @@ class SentryConfig { const sentryDist = String.fromEnvironment('SENTRY_DIST'); logTrace( - 'SentryConfig::load: sentryDist is $sentryDist,' + 'SentryConfig::load: sentryDist is $sentryDist, ' 'appVersion is $appVersion', webConsoleEnabled: true, ); diff --git a/lib/features/push_notification/domain/exceptions/fcm_exception.dart b/lib/features/push_notification/domain/exceptions/fcm_exception.dart index e450ea3f4..3be8f8ea1 100644 --- a/lib/features/push_notification/domain/exceptions/fcm_exception.dart +++ b/lib/features/push_notification/domain/exceptions/fcm_exception.dart @@ -1,84 +1,84 @@ import 'package:core/domain/exceptions/app_base_exception.dart'; class NotSupportFCMException extends AppBaseException { - NotSupportFCMException([super.message]); + const NotSupportFCMException([super.message]); @override String get exceptionName => 'NotSupportFCMException'; } class NotLoadedFCMTokenException extends AppBaseException { - NotLoadedFCMTokenException([super.message]); + const NotLoadedFCMTokenException([super.message]); @override String get exceptionName => 'NotLoadedFCMTokenException'; } class NotFoundStateToRefreshException extends AppBaseException { - NotFoundStateToRefreshException([super.message]); + const NotFoundStateToRefreshException([super.message]); @override String get exceptionName => 'NotFoundStateToRefreshException'; } class NotFoundEmailDeliveryStateException extends AppBaseException { - NotFoundEmailDeliveryStateException([super.message]); + const NotFoundEmailDeliveryStateException([super.message]); @override String get exceptionName => 'NotFoundEmailDeliveryStateException'; } class NotFoundFirebaseRegistrationForDeviceException extends AppBaseException { - NotFoundFirebaseRegistrationForDeviceException([super.message]); + const NotFoundFirebaseRegistrationForDeviceException([super.message]); @override String get exceptionName => 'NotFoundFirebaseRegistrationForDeviceException'; } class NotFoundFirebaseRegistrationCacheException extends AppBaseException { - NotFoundFirebaseRegistrationCacheException([super.message]); + const NotFoundFirebaseRegistrationCacheException([super.message]); @override String get exceptionName => 'NotFoundFirebaseRegistrationCacheException'; } class NotFoundEmailStateException extends AppBaseException { - NotFoundEmailStateException([super.message]); + const NotFoundEmailStateException([super.message]); @override String get exceptionName => 'NotFoundEmailStateException'; } class NotFoundNewReceiveEmailException extends AppBaseException { - NotFoundNewReceiveEmailException([super.message]); + const NotFoundNewReceiveEmailException([super.message]); @override String get exceptionName => 'NotFoundNewReceiveEmailException'; } class EmailStateNoChangeException extends AppBaseException { - EmailStateNoChangeException([super.message]); + const EmailStateNoChangeException([super.message]); @override String get exceptionName => 'EmailStateNoChangeException'; } class NotFoundFirebaseRegistrationCreatedException extends AppBaseException { - NotFoundFirebaseRegistrationCreatedException([super.message]); + const NotFoundFirebaseRegistrationCreatedException([super.message]); @override String get exceptionName => 'NotFoundFirebaseRegistrationCreatedException'; } class NotFoundFirebaseRegistrationUpdatedException extends AppBaseException { - NotFoundFirebaseRegistrationUpdatedException([super.message]); + const NotFoundFirebaseRegistrationUpdatedException([super.message]); @override String get exceptionName => 'NotFoundFirebaseRegistrationUpdatedException'; } class NotFoundFirebaseRegistrationDestroyedException extends AppBaseException { - NotFoundFirebaseRegistrationDestroyedException([super.message]); + const NotFoundFirebaseRegistrationDestroyedException([super.message]); @override String get exceptionName => 'NotFoundFirebaseRegistrationDestroyedException'; diff --git a/lib/main/exceptions/cache_exception.dart b/lib/main/exceptions/cache_exception.dart index ae90e3677..f46f1ef68 100644 --- a/lib/main/exceptions/cache_exception.dart +++ b/lib/main/exceptions/cache_exception.dart @@ -9,7 +9,7 @@ abstract class CacheException with EquatableMixin implements Exception { @override String toString() { - if (message != null) { + if (message?.trim().isNotEmpty == true) { return '$exceptionName: $message'; } return exceptionName; diff --git a/lib/main/exceptions/remote_exception.dart b/lib/main/exceptions/remote_exception.dart index ab638fddf..751c77b59 100644 --- a/lib/main/exceptions/remote_exception.dart +++ b/lib/main/exceptions/remote_exception.dart @@ -112,10 +112,12 @@ class NoNetworkError extends RemoteException { class RefreshTokenFailedException extends RemoteException { RefreshTokenFailedException({ - super.message = - 'Refresh Token failed with 400 Bad Request. The session is invalid/revoked.', - super.code = 400, - }); + int code = 400, + Object? message + }) : super( + code: code, + message: message ?? 'Refresh Token failed with 400 Bad Request. The session is invalid/revoked.', +); @override String get exceptionName => 'RefreshTokenFailedException'; diff --git a/model/lib/exceptions/token_oidc_exceptions.dart b/model/lib/exceptions/token_oidc_exceptions.dart index 5daec652c..84e76e29a 100644 --- a/model/lib/exceptions/token_oidc_exceptions.dart +++ b/model/lib/exceptions/token_oidc_exceptions.dart @@ -1,28 +1,28 @@ import 'package:core/domain/exceptions/app_base_exception.dart'; class AccessTokenIsNullException extends AppBaseException { - AccessTokenIsNullException([super.message]); + const AccessTokenIsNullException([super.message]); @override String get exceptionName => 'AccessTokenIsNullException'; } class RefreshTokenIsNullException extends AppBaseException { - RefreshTokenIsNullException([super.message]); + const RefreshTokenIsNullException([super.message]); @override String get exceptionName => 'RefreshTokenIsNullException'; } class TokenIdIsNullException extends AppBaseException { - TokenIdIsNullException([super.message]); + const TokenIdIsNullException([super.message]); @override String get exceptionName => 'TokenIdIsNullException'; } class ExpiresTimeIsNullException extends AppBaseException { - ExpiresTimeIsNullException([super.message]); + const ExpiresTimeIsNullException([super.message]); @override String get exceptionName => 'ExpiresTimeIsNullException';