TF-4136 refactor(logging): replace logError with logWarning for non-critical cases

This commit is contained in:
dab246
2026-01-02 12:18:38 +07:00
committed by Dat H. Pham
parent 73dcb6067c
commit a23d15a9ca
160 changed files with 382 additions and 360 deletions
@@ -61,7 +61,7 @@ class AccountCacheManager extends CacheManagerInteraction {
await _accountCacheClient.insertMultipleItem(legacyMapItems);
log('$runtimeType::migrateHiveToIsolatedHive(): ✅ Migrate Hive box "${_accountCacheClient.tableName}" → IsolatedHive DONE');
} catch (e) {
logError('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_accountCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
logWarning('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_accountCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
}
}
}
@@ -38,7 +38,7 @@ class AuthenticationInfoCacheManager extends CacheManagerInteraction {
await _authenticationInfoCacheClient.insertMultipleItem(legacyMapItems);
log('$runtimeType::migrateHiveToIsolatedHive(): ✅ Migrate Hive box "${_authenticationInfoCacheClient.tableName}" → IsolatedHive DONE');
} catch (e) {
logError('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_authenticationInfoCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
logWarning('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_authenticationInfoCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
}
}
}
@@ -28,7 +28,7 @@ class EncryptionKeyCacheManager extends CacheManagerInteraction {
await _encryptionKeyCacheClient.insertMultipleItem(legacyMapItems);
log('$runtimeType::migrateHiveToIsolatedHive(): ✅ Migrate Hive box "${_encryptionKeyCacheClient.tableName}" → IsolatedHive DONE');
} catch (e) {
logError('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_encryptionKeyCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
logWarning('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_encryptionKeyCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
}
}
}
@@ -63,7 +63,7 @@ class OidcConfigurationCacheManager extends CacheManagerInteraction {
await _oidcConfigurationCacheClient.insertMultipleItem(legacyMapItems);
log('$runtimeType::migrateHiveToIsolatedHive(): ✅ Migrate Hive box "${_oidcConfigurationCacheClient.tableName}" → IsolatedHive DONE');
} catch (e) {
logError('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_oidcConfigurationCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
logWarning('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_oidcConfigurationCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
}
}
}
@@ -46,7 +46,7 @@ class TokenOidcCacheManager extends CacheManagerInteraction {
await _tokenOidcCacheClient.insertMultipleItem(legacyMapItems);
log('$runtimeType::migrateHiveToIsolatedHive(): ✅ Migrate Hive box "${_tokenOidcCacheClient.tableName}" → IsolatedHive DONE');
} catch (e) {
logError('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_tokenOidcCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
logWarning('$runtimeType::migrateHiveToIsolatedHive(): ❌ Migrate Hive box "${_tokenOidcCacheClient.tableName}" → IsolatedHive FAILED, Error: $e');
}
}
}
@@ -74,7 +74,7 @@ mixin AuthenticationClientInteractionMixin {
dynamic handleException(dynamic exception) {
if (exception is FlutterAppAuthPlatformException) {
logError('$runtimeType::handleException: ErrorDetails = ${exception.platformErrorDetails.toString()}');
logWarning('$runtimeType::handleException: ErrorDetails = ${exception.platformErrorDetails.toString()}');
final errorCode = exception.platformErrorDetails.error;
if (errorCode != null) {
final oauthErrorCode = OAuthAuthorizationError.fromErrorCode(
@@ -92,7 +92,7 @@ class AuthenticationClientMobile with AuthenticationClientInteractionMixin
throw AccessTokenInvalidException();
}
} catch (e) {
logError('$runtimeType::refreshingTokensOIDC(): $e');
logWarning('$runtimeType::refreshingTokensOIDC(): $e');
throw handleException(e);
}
}
@@ -89,7 +89,7 @@ class AuthenticationClientWeb with AuthenticationClientInteractionMixin
throw AccessTokenInvalidException();
}
} catch (e) {
logError('$runtimeType::refreshingTokensOIDC(): $e');
logWarning('$runtimeType::refreshingTokensOIDC(): $e');
throw handleException(e);
}
}
@@ -70,10 +70,10 @@ class DnsLookupManager {
}
log('$runtimeType::lookupJmapUrl → ⚠️ No records via ${priority.label}, continuing...');
} on TimeoutException catch (_) {
logError(
logWarning(
'$runtimeType::lookupJmapUrl → ⏱️ ${priority.label} lookup timed out');
} catch (error, stack) {
logError(
logWarning(
'$runtimeType::lookupJmapUrl → ❌ ${priority.label} lookup failed: $error, $stack');
}
}
@@ -83,7 +83,7 @@ class AuthorizationInterceptors extends QueuedInterceptorsWrapper {
@override
void onError(DioError err, ErrorInterceptorHandler handler) async {
logError('AuthorizationInterceptors::onError(): DIO_ERROR = $err');
logWarning('AuthorizationInterceptors::onError(): DIO_ERROR = $err');
try {
final requestOptions = err.requestOptions;
final extraInRequest = requestOptions.extra;
@@ -151,8 +151,12 @@ class AuthorizationInterceptors extends QueuedInterceptorsWrapper {
} else {
return super.onError(err, handler);
}
} catch (e) {
logError('AuthorizationInterceptors::onError:Exception: $e');
} catch (e, stackTrace) {
logError(
'AuthorizationInterceptors::onError:Exception: $e',
exception: e,
stackTrace: stackTrace,
);
if (e is ServerError || e is TemporarilyUnavailable) {
return super.onError(
DioError(requestOptions: err.requestOptions, error: e),
@@ -166,14 +170,17 @@ class AuthorizationInterceptors extends QueuedInterceptorsWrapper {
Stream<List<int>>? _getDataUploadRequest(dynamic mapUploadExtra) {
try {
String? filePath = mapUploadExtra[FileUploader.filePathExtraKey];
if (mapUploadExtra is! Map) return null;
final filePath = mapUploadExtra[FileUploader.filePathExtraKey] as String?;
if (filePath?.isNotEmpty == true) {
return File(filePath!).openRead();
} else {
return mapUploadExtra[FileUploader.streamDataExtraKey];
return mapUploadExtra[FileUploader.streamDataExtraKey] as Stream<List<int>>?;
}
} catch(e) {
log('AuthorizationInterceptors::_getDataUploadRequest: Exception = $e');
logWarning(
'AuthorizationInterceptors::_getDataUploadRequest: Exception = $e',
);
return null;
}
}
@@ -24,7 +24,7 @@ class AuthenticateOidcOnBrowserInteractor {
config.scopes);
yield Right<Failure, Success>(AuthenticateOidcOnBrowserSuccess());
} catch (e) {
logError('AuthenticateOidcOnBrowserInteractor::execute(): $e');
logWarning('AuthenticateOidcOnBrowserInteractor::execute(): $e');
yield Left<Failure, Success>(AuthenticateOidcOnBrowserFailure(e));
}
}
@@ -28,7 +28,7 @@ class GetOIDCConfigurationInteractor {
GetOIDCConfigurationSuccess(configWithLoginHint),
);
} catch (e) {
logError('$runtimeType::execute():oidcResponse = ${oidcResponse.runtimeType} | Exception = $e');
logWarning('$runtimeType::execute():oidcResponse = ${oidcResponse.runtimeType} | Exception = $e');
if (oidcResponse is BaseUrlOidcResponse) {
yield Left<Failure, Success>(GetOIDCConfigurationFromBaseUrlFailure(e));
} else {
@@ -53,14 +53,14 @@ class GetTokenOIDCInteractor {
baseUri,
));
} on PlatformException catch (e) {
logError('GetTokenOIDCInteractor::execute(): PlatformException ${e.message} - ${e.stacktrace}');
logWarning('GetTokenOIDCInteractor::execute(): PlatformException ${e.message} - ${e.stacktrace}');
if (NoSuitableBrowserForOIDCException.verifyException(e)) {
yield Left<Failure, Success>(GetTokenOIDCFailure(NoSuitableBrowserForOIDCException()));
} else {
yield Left<Failure, Success>(GetTokenOIDCFailure(e));
}
} catch (e) {
logError('GetTokenOIDCInteractor::execute(): $e');
logWarning('GetTokenOIDCInteractor::execute(): $e');
yield Left<Failure, Success>(GetTokenOIDCFailure(e));
}
}
@@ -43,7 +43,7 @@ class TryGuessingWebFingerInteractor {
yield Right(TryGuessingWebFingerSuccess(firstNonNullResponse));
}
} catch (e) {
logError('$runtimeType::execute(): Exception = $e');
logWarning('$runtimeType::execute(): Exception = $e');
yield Left(TryGuessingWebFingerFailure(exception: e));
}
}
@@ -45,7 +45,7 @@ class UpdateAccountCacheInteractor {
try {
return session.getQualifiedApiUrl(baseUrl: baseUrl);
} catch (e) {
logError('UpdateAccountCacheInteractor::_getQualifiedApiUrl:Exception = $e');
logWarning('UpdateAccountCacheInteractor::_getQualifiedApiUrl:Exception = $e');
return '';
}
}
@@ -224,7 +224,7 @@ class LoginController extends ReloadableController {
@override
void handleUrgentException({Failure? failure, Exception? exception}) {
logError('LoginController::handleUrgentException:Exception: $exception | Failure: $failure');
logWarning('LoginController::handleUrgentException:Exception: $exception | Failure: $failure');
if (failure is CheckOIDCIsAvailableFailure) {
_handleCheckOIDCIsAvailableFailure(failure);
} else if (failure is GetOIDCConfigurationFromBaseUrlFailure) {
@@ -316,7 +316,7 @@ class LoginController extends ReloadableController {
featureFailure = failure;
tryGetOIDCConfigurationFromBaseUrl(_currentBaseUrl!);
} catch (e) {
logError('LoginController::_handleCheckOIDCIsAvailableFailure:Exception = $e');
logWarning('LoginController::_handleCheckOIDCIsAvailableFailure:Exception = $e');
handleOIDCIsNotAvailable(failure);
}
}