refactor(sentry): standardize exceptions to prevent Sentry minification
This commit is contained in:
@@ -60,7 +60,7 @@ class MailboxIsolateWorker {
|
||||
} else {
|
||||
final rootIsolateToken = RootIsolateToken.instance;
|
||||
if (rootIsolateToken == null) {
|
||||
throw CanNotGetRootIsolateToken();
|
||||
throw const CanNotGetRootIsolateToken();
|
||||
}
|
||||
|
||||
final result = await _isolateExecutor.execute(
|
||||
@@ -227,7 +227,7 @@ class MailboxIsolateWorker {
|
||||
}) async {
|
||||
final rootIsolateToken = RootIsolateToken.instance;
|
||||
if (rootIsolateToken == null) {
|
||||
throw CanNotGetRootIsolateToken();
|
||||
throw const CanNotGetRootIsolateToken();
|
||||
}
|
||||
|
||||
final countEmailsCompleted = await _isolateExecutor.execute(
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class EmptyFolderNameException implements Exception {
|
||||
class EmptyFolderNameException extends AppBaseException {
|
||||
final String folderName;
|
||||
|
||||
EmptyFolderNameException(this.folderName);
|
||||
EmptyFolderNameException(this.folderName)
|
||||
: super('Folder name should not be empty: $folderName');
|
||||
|
||||
@override
|
||||
String toString() => 'EmptyFolderNameException: Folder name should not be empty: $folderName';
|
||||
String get exceptionName => 'EmptyFolderNameException';
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class InvalidMailFormatException implements Exception {
|
||||
class InvalidMailFormatException extends AppBaseException {
|
||||
final String mail;
|
||||
|
||||
InvalidMailFormatException(this.mail);
|
||||
InvalidMailFormatException(this.mail) : super('Email: $mail');
|
||||
|
||||
@override
|
||||
String toString() => 'InvalidMailFormatException: $mail';
|
||||
String get exceptionName => 'InvalidMailFormatException';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class NotFoundInboxMailboxException implements Exception {}
|
||||
class NotFoundInboxMailboxException extends AppBaseException {
|
||||
NotFoundInboxMailboxException([super.message]);
|
||||
|
||||
class NotFoundMailboxException implements Exception {}
|
||||
@override
|
||||
String get exceptionName => 'NotFoundInboxMailboxException';
|
||||
}
|
||||
|
||||
class NotFoundClearMailboxResponseException implements Exception {}
|
||||
class NotFoundMailboxException extends AppBaseException {
|
||||
NotFoundMailboxException([super.message]);
|
||||
|
||||
class CannotMoveAllEmailException implements Exception {}
|
||||
@override
|
||||
String get exceptionName => 'NotFoundMailboxException';
|
||||
}
|
||||
|
||||
class NotFoundClearMailboxResponseException extends AppBaseException {
|
||||
NotFoundClearMailboxResponseException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'NotFoundClearMailboxResponseException';
|
||||
}
|
||||
|
||||
class CannotMoveAllEmailException extends AppBaseException {
|
||||
CannotMoveAllEmailException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'CannotMoveAllEmailException';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class NullSessionOrAccountIdException implements Exception {
|
||||
|
||||
NullSessionOrAccountIdException();
|
||||
class NullSessionOrAccountIdException extends AppBaseException {
|
||||
NullSessionOrAccountIdException(
|
||||
[super.message = 'session and accountId should not be null']);
|
||||
|
||||
@override
|
||||
String toString() => 'NullSessionOrAccountIdException: session and accountId should not be null';
|
||||
String get exceptionName => 'NullSessionOrAccountIdException';
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
class NotFoundMailboxCreatedException implements Exception {}
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class NotFoundMailboxUpdatedRoleException implements Exception {}
|
||||
class NotFoundMailboxCreatedException extends AppBaseException {
|
||||
NotFoundMailboxCreatedException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'NotFoundMailboxCreatedException';
|
||||
}
|
||||
|
||||
class NotFoundMailboxUpdatedRoleException extends AppBaseException {
|
||||
NotFoundMailboxUpdatedRoleException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'NotFoundMailboxUpdatedRoleException';
|
||||
}
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class SetMailboxNameException implements Exception {
|
||||
static const emptyMailboxNameDescription = 'has an empty part within its mailbox name';
|
||||
static const mailboxNameContainsInvalidCharactersDescription = 'contains one of the forbidden characters';
|
||||
class SetMailboxNameException extends AppBaseException {
|
||||
static const emptyMailboxNameDescription =
|
||||
'has an empty part within its mailbox name';
|
||||
static const mailboxNameContainsInvalidCharactersDescription =
|
||||
'contains one of the forbidden characters';
|
||||
|
||||
static SetMailboxNameException detectMailboxNameException(Object exception, MailboxId mailboxId) {
|
||||
SetMailboxNameException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'SetMailboxNameException';
|
||||
|
||||
static SetMailboxNameException detectMailboxNameException(
|
||||
Object exception, MailboxId mailboxId) {
|
||||
if (exception is SetMethodException) {
|
||||
final setError = exception.mapErrors[mailboxId.id];
|
||||
if (setError == null) {
|
||||
@@ -19,15 +28,30 @@ class SetMailboxNameException implements Exception {
|
||||
|
||||
if (errorDescription.contains(emptyMailboxNameDescription)) {
|
||||
return EmptyMailboxNameException();
|
||||
} else if (errorDescription.contains(mailboxNameContainsInvalidCharactersDescription)) {
|
||||
} else if (errorDescription
|
||||
.contains(mailboxNameContainsInvalidCharactersDescription)) {
|
||||
return ContainsInvalidCharactersMailboxNameException();
|
||||
}
|
||||
return SetMailboxNameException();
|
||||
return SetMailboxNameException(errorDescription);
|
||||
}
|
||||
return SetMailboxNameException();
|
||||
}
|
||||
}
|
||||
|
||||
class EmptyMailboxNameException implements SetMailboxNameException {}
|
||||
class EmptyMailboxNameException extends SetMailboxNameException {
|
||||
EmptyMailboxNameException()
|
||||
: super(SetMailboxNameException.emptyMailboxNameDescription);
|
||||
|
||||
class ContainsInvalidCharactersMailboxNameException implements SetMailboxNameException {}
|
||||
@override
|
||||
String get exceptionName => 'EmptyMailboxNameException';
|
||||
}
|
||||
|
||||
class ContainsInvalidCharactersMailboxNameException
|
||||
extends SetMailboxNameException {
|
||||
ContainsInvalidCharactersMailboxNameException()
|
||||
: super(SetMailboxNameException
|
||||
.mailboxNameContainsInvalidCharactersDescription);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'ContainsInvalidCharactersMailboxNameException';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class SetMailboxRightsException implements Exception {
|
||||
|
||||
SetMailboxRightsException();
|
||||
class SetMailboxRightsException extends AppBaseException {
|
||||
SetMailboxRightsException(
|
||||
[super.message = 'Failed to update mailbox rights.']);
|
||||
|
||||
@override
|
||||
String toString() => 'Failed to update mailbox rights.';
|
||||
}
|
||||
String get exceptionName => 'SetMailboxRightsException';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user