refactor(sentry): standardize exceptions to prevent Sentry minification

This commit is contained in:
dab246
2026-02-24 15:40:07 +07:00
committed by Dat H. Pham
parent 296548a781
commit 2e8a11e7eb
75 changed files with 1128 additions and 309 deletions
+17 -9
View File
@@ -1,18 +1,26 @@
import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
import 'package:core/domain/exceptions/app_base_exception.dart';
class InvalidCapability extends AppBaseException with EquatableMixin {
const InvalidCapability([super.message]);
@override
String get exceptionName => 'InvalidCapability';
@override
List<Object?> get props => [message];
}
class SessionMissingCapability extends InvalidCapability {
final Set<CapabilityIdentifier> capabilityIdentifiers;
const SessionMissingCapability(this.capabilityIdentifiers) : super();
const SessionMissingCapability(this.capabilityIdentifiers)
: super('Missing capabilities $capabilityIdentifiers');
@override
List<Object?> get props => [capabilityIdentifiers];
String get exceptionName => 'SessionMissingCapability';
@override
List<Object?> get props => [capabilityIdentifiers, ...super.props];
}
class InvalidCapability extends Equatable implements Exception {
const InvalidCapability();
@override
List<Object?> get props => [];
}
+15 -4
View File
@@ -1,16 +1,27 @@
import 'package:equatable/equatable.dart';
abstract class CacheException with EquatableMixin implements Exception {
final String? message;
const CacheException({this.message});
String get exceptionName;
@override
String toString() {
if (message != null) {
return '$exceptionName: $message';
}
return exceptionName;
}
}
class UnknownCacheError extends CacheException {
const UnknownCacheError({String? message}) : super(message: message);
@override
List<Object> get props => [];
}
String get exceptionName => 'UnknownCacheError';
@override
List<Object?> get props => [message];
}
+8 -1
View File
@@ -1 +1,8 @@
class CanNotGetRootIsolateToken implements Exception {}
import 'package:core/domain/exceptions/app_base_exception.dart';
class CanNotGetRootIsolateToken extends AppBaseException {
const CanNotGetRootIsolateToken([super.message]);
@override
String get exceptionName => 'CanNotGetRootIsolateToken';
}
+8 -1
View File
@@ -1 +1,8 @@
class InteractorNotInitialized implements Exception {}
import 'package:core/domain/exceptions/app_base_exception.dart';
class InteractorNotInitialized extends AppBaseException {
const InteractorNotInitialized([super.message]);
@override
String get exceptionName => 'InteractorNotInitialized';
}
+17 -4
View File
@@ -1,15 +1,28 @@
import 'package:equatable/equatable.dart';
abstract class PermissionException with EquatableMixin implements Exception {
final String? message;
const PermissionException({this.message});
String get exceptionName;
@override
String toString() {
if (message != null) {
return '$exceptionName: $message';
}
return exceptionName;
}
}
class NotGrantedPermissionStorageException extends PermissionException {
const NotGrantedPermissionStorageException() : super(message: 'Permission Storage has not been granted access');
const NotGrantedPermissionStorageException()
: super(message: 'Permission Storage has not been granted access');
@override
List<Object?> get props => [super.message];
}
String get exceptionName => 'NotGrantedPermissionStorageException';
@override
List<Object?> get props => [message];
}
+61 -14
View File
@@ -1,4 +1,3 @@
import 'package:equatable/equatable.dart';
import 'package:jmap_dart_client/jmap/core/error/error_type.dart';
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
@@ -16,52 +15,98 @@ abstract class RemoteException with EquatableMixin implements Exception {
const RemoteException({this.code, this.message});
String get exceptionName;
@override
String toString() {
if (code != null) {
return '$exceptionName(code: $code): $message';
}
return '$exceptionName: $message';
}
@override
List<Object?> get props => [message, code];
}
class BadCredentialsException extends RemoteException {
const BadCredentialsException() : super(message: RemoteException.badCredentials);
const BadCredentialsException()
: super(message: RemoteException.badCredentials);
@override
String get exceptionName => 'BadCredentialsException';
}
class UnknownError extends RemoteException {
const UnknownError({int? code, Object? message}) : super(code: code, message: message);
const UnknownError({int? code, Object? message})
: super(code: code, message: message);
@override
String get exceptionName => 'UnknownError';
}
class ConnectionError extends RemoteException {
const ConnectionError({String? message}) : super(message: message ?? RemoteException.connectionError);
const ConnectionError({String? message})
: super(message: message ?? RemoteException.connectionError);
@override
String get exceptionName => 'ConnectionError';
}
class ConnectionTimeout extends RemoteException {
const ConnectionTimeout({String? message}) : super(message: message ?? RemoteException.connectionTimeout);
const ConnectionTimeout({String? message})
: super(message: message ?? RemoteException.connectionTimeout);
@override
String get exceptionName => 'ConnectionTimeout';
}
class SocketError extends RemoteException {
const SocketError() : super(message: RemoteException.socketException);
@override
String get exceptionName => 'SocketError';
}
class InternalServerError extends RemoteException {
const InternalServerError() : super(message: RemoteException.internalServerError);
const InternalServerError()
: super(message: RemoteException.internalServerError);
@override
String get exceptionName => 'InternalServerError';
}
class MethodLevelErrors extends RemoteException {
final ErrorType type;
const MethodLevelErrors(
this.type,
{String? message}
) : super(message: message);
const MethodLevelErrors(this.type, {String? message})
: super(message: message);
@override
String get exceptionName => 'MethodLevelErrors';
@override
String toString() {
return '$exceptionName(type: $type): $message';
}
@override
List<Object?> get props => [type, ...super.props];
}
class CannotCalculateChangesMethodResponseException extends MethodLevelErrors {
CannotCalculateChangesMethodResponseException({String? message}) : super(ErrorMethodResponse.cannotCalculateChanges, message: message);
CannotCalculateChangesMethodResponseException({String? message})
: super(ErrorMethodResponse.cannotCalculateChanges, message: message);
@override
String get exceptionName => 'CannotCalculateChangesMethodResponseException';
}
class NoNetworkError extends RemoteException {
const NoNetworkError() : super(message: RemoteException.noNetworkError);
@override
String get exceptionName => 'NoNetworkError';
}
class RefreshTokenFailedException extends RemoteException {
@@ -74,6 +119,8 @@ class RefreshTokenFailedException extends RemoteException {
});
@override
String toString() =>
"RefreshTokenFailedException(status: $statusCode): $message";
}
String get exceptionName => 'RefreshTokenFailedException';
@override
String toString() => "$exceptionName(status: $statusCode): $message";
}
+6 -6
View File
@@ -20,21 +20,21 @@ import 'package:model/email/email_action_type.dart';
import 'package:model/email/mark_star_action.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
import 'package:tmail_ui_user/features/download/domain/state/parse_email_by_blob_id_state.dart';
import 'package:tmail_ui_user/features/download/domain/state/preview_email_from_eml_file_state.dart';
import 'package:tmail_ui_user/features/email/domain/exceptions/calendar_event_exceptions.dart';
import 'package:tmail_ui_user/features/email/domain/model/move_action.dart';
import 'package:tmail_ui_user/features/email/domain/state/add_a_label_to_an_email_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/add_a_label_to_a_thread_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/add_a_label_to_an_email_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_reply_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/labels/remove_a_label_from_a_thread_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/mark_as_email_star_state.dart';
import 'package:tmail_ui_user/features/download/domain/state/parse_email_by_blob_id_state.dart';
import 'package:tmail_ui_user/features/download/domain/state/preview_email_from_eml_file_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/remove_a_label_from_an_email_state.dart';
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
import 'package:tmail_ui_user/features/home/domain/state/get_session_state.dart';
import 'package:tmail_ui_user/features/labels/domain/state/create_new_label_state.dart';
import 'package:tmail_ui_user/features/labels/domain/state/edit_label_state.dart';
import 'package:tmail_ui_user/features/labels/domain/state/delete_a_label_state.dart';
import 'package:tmail_ui_user/features/labels/domain/state/edit_label_state.dart';
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
import 'package:tmail_ui_user/features/login/domain/exceptions/oauth_authorization_error.dart';
@@ -133,9 +133,9 @@ class ToastManager {
return '[${firstError.type.value}] ${firstError.description}';
}
} else if (exception is ServerError) {
return '[${exception.error}] ${exception.errorDescription}';
return '[${exception.error}] ${exception.message}';
} else if (exception is TemporarilyUnavailable) {
return '[${exception.error}] ${exception.errorDescription}';
return '[${exception.error}] ${exception.message}';
} else if (exception is AutoRedirectToAppAfterStoreAuthorizeDestinationUrlException) {
return '';
}