refactor(sentry): standardize exceptions to prevent Sentry minification
This commit is contained in:
@@ -25,6 +25,7 @@ export 'domain/exceptions/download_file_exception.dart';
|
||||
export 'data/extensions/options_extensions.dart';
|
||||
export 'domain/exceptions/web_session_exception.dart';
|
||||
export 'domain/exceptions/platform_exception.dart';
|
||||
export 'domain/exceptions/app_base_exception.dart';
|
||||
|
||||
// Utils
|
||||
export 'presentation/utils/theme_utils.dart';
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class AddressException with EquatableMixin implements Exception {
|
||||
final String message;
|
||||
|
||||
AddressException(this.message);
|
||||
class AddressException extends AppBaseException with EquatableMixin {
|
||||
const AddressException(super.message);
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
String get exceptionName => 'AddressException';
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
abstract class AppBaseException implements Exception {
|
||||
final String? message;
|
||||
|
||||
const AppBaseException([this.message]);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
if (message != null && message!.isNotEmpty) {
|
||||
return '$exceptionName: $message';
|
||||
}
|
||||
return exceptionName;
|
||||
}
|
||||
|
||||
String get exceptionName;
|
||||
}
|
||||
@@ -1,31 +1,32 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class DownloadFileException with EquatableMixin implements Exception {
|
||||
final String message;
|
||||
|
||||
DownloadFileException(this.message);
|
||||
abstract class DownloadFileException extends AppBaseException
|
||||
with EquatableMixin {
|
||||
const DownloadFileException(super.message);
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
class CommonDownloadFileException extends DownloadFileException {
|
||||
CommonDownloadFileException(message) : super(message);
|
||||
const CommonDownloadFileException(super.message);
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
String get exceptionName => 'CommonDownloadFileException';
|
||||
}
|
||||
|
||||
class CancelDownloadFileException extends DownloadFileException {
|
||||
CancelDownloadFileException(cancelMessage) : super(cancelMessage);
|
||||
const CancelDownloadFileException(super.message);
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
String get exceptionName => 'CancelDownloadFileException';
|
||||
}
|
||||
|
||||
class DeviceNotSupportedException extends DownloadFileException {
|
||||
DeviceNotSupportedException() : super('This device is not supported, please try on Android or iOS');
|
||||
}
|
||||
const DeviceNotSupportedException()
|
||||
: super('This device is not supported, please try on Android or iOS');
|
||||
|
||||
@override
|
||||
String get exceptionName => 'DeviceNotSupportedException';
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class FileException with EquatableMixin implements Exception {
|
||||
final String message;
|
||||
|
||||
FileException(this.message);
|
||||
abstract class FileException extends AppBaseException with EquatableMixin {
|
||||
const FileException(super.message);
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
class NotFoundFileInFolderException extends FileException {
|
||||
NotFoundFileInFolderException() : super('No files found in the folder');
|
||||
|
||||
@override
|
||||
String get exceptionName => 'NotFoundFileInFolderException';
|
||||
}
|
||||
|
||||
class UserCancelShareFileException extends FileException {
|
||||
UserCancelShareFileException() : super('User cancel share file');
|
||||
}
|
||||
|
||||
@override
|
||||
String get exceptionName => 'UserCancelShareFileException';
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class PlatformException with EquatableMixin implements Exception {
|
||||
final String message;
|
||||
|
||||
PlatformException(this.message);
|
||||
class PlatformException extends AppBaseException with EquatableMixin {
|
||||
const PlatformException(super.message);
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
String get exceptionName => 'PlatformException';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
class NoSupportPlatformException extends PlatformException {
|
||||
NoSupportPlatformException() : super('This platform is not supported');
|
||||
}
|
||||
const NoSupportPlatformException() : super('This platform is not supported');
|
||||
|
||||
@override
|
||||
String get exceptionName => 'NoSupportPlatformException';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
class UnsupportedCharsetException implements Exception {
|
||||
const UnsupportedCharsetException();
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
|
||||
class UnsupportedCharsetException extends AppBaseException {
|
||||
const UnsupportedCharsetException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'UnsupportedCharsetException';
|
||||
}
|
||||
|
||||
class NullCharsetException implements Exception {
|
||||
const NullCharsetException();
|
||||
}
|
||||
class NullCharsetException extends AppBaseException {
|
||||
const NullCharsetException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'NullCharsetException';
|
||||
}
|
||||
|
||||
@@ -1,28 +1,44 @@
|
||||
import 'package:core/domain/exceptions/app_base_exception.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class NotFoundInWebSessionException with EquatableMixin implements Exception {
|
||||
final String? errorMessage;
|
||||
|
||||
NotFoundInWebSessionException({this.errorMessage});
|
||||
class NotFoundInWebSessionException extends AppBaseException
|
||||
with EquatableMixin {
|
||||
const NotFoundInWebSessionException({String? errorMessage})
|
||||
: super(errorMessage);
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class NotMatchInWebSessionException with EquatableMixin implements Exception {
|
||||
const NotMatchInWebSessionException();
|
||||
String get exceptionName => 'NotFoundInWebSessionException';
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
class SaveToWebSessionFailException with EquatableMixin implements Exception {
|
||||
final String? errorMessage;
|
||||
|
||||
SaveToWebSessionFailException({this.errorMessage});
|
||||
class NotMatchInWebSessionException extends AppBaseException
|
||||
with EquatableMixin {
|
||||
const NotMatchInWebSessionException() : super('Session data does not match');
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
String get exceptionName => 'NotMatchInWebSessionException';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
class CannotOpenNewWindowException implements Exception {}
|
||||
class SaveToWebSessionFailException extends AppBaseException
|
||||
with EquatableMixin {
|
||||
const SaveToWebSessionFailException({String? errorMessage})
|
||||
: super(errorMessage);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'SaveToWebSessionFailException';
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message, exceptionName];
|
||||
}
|
||||
|
||||
class CannotOpenNewWindowException extends AppBaseException {
|
||||
const CannotOpenNewWindowException([super.message]);
|
||||
|
||||
@override
|
||||
String get exceptionName => 'CannotOpenNewWindowException';
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class FileUtils {
|
||||
|
||||
return fileDirectory;
|
||||
} else {
|
||||
throw DeviceNotSupportedException();
|
||||
throw const DeviceNotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class LogTracking {
|
||||
|
||||
return fileDirectory;
|
||||
} else {
|
||||
throw DeviceNotSupportedException();
|
||||
throw const DeviceNotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class MailAddress with EquatableMixin {
|
||||
|
||||
address = address.trim();
|
||||
if (address.isEmpty) {
|
||||
throw AddressException('Addresses should not be empty');
|
||||
throw const AddressException('Addresses should not be empty');
|
||||
}
|
||||
int pos = 0;
|
||||
|
||||
@@ -88,7 +88,7 @@ class MailAddress with EquatableMixin {
|
||||
if (postChar == '.') {
|
||||
var lastChar = address[pos - 1];
|
||||
if (lastChar == '@' || lastChar == '.') {
|
||||
throw AddressException('Subdomain expected before "." or duplicate "." in "address"');
|
||||
throw const AddressException('Subdomain expected before "." or duplicate "." in "address"');
|
||||
}
|
||||
domainSB.write('.');
|
||||
pos++;
|
||||
@@ -113,7 +113,7 @@ class MailAddress with EquatableMixin {
|
||||
if (localPart.startsWith('.') ||
|
||||
localPart.endsWith('.') ||
|
||||
_haveDoubleDot(localPart)) {
|
||||
throw AddressException('Addresses cannot start end with "." or contain two consecutive dots');
|
||||
throw const AddressException('Addresses cannot start end with "." or contain two consecutive dots');
|
||||
}
|
||||
|
||||
domain = _createDomain(domainSB.toString());
|
||||
@@ -409,7 +409,7 @@ class MailAddress with EquatableMixin {
|
||||
lastCharDot = false;
|
||||
} else if (postChar == '.') {
|
||||
if (pos == 0) {
|
||||
throw AddressException('Local part must not start with a "."');
|
||||
throw const AddressException('Local part must not start with a "."');
|
||||
}
|
||||
lpSB.write('.');
|
||||
pos++;
|
||||
@@ -530,14 +530,14 @@ class MailAddress with EquatableMixin {
|
||||
|
||||
String localPartDetails = localPartDetailsSB.toString();
|
||||
if (localPartDetails.isEmpty || localPartDetails.trim().isEmpty) {
|
||||
throw AddressException("target mailbox name should not be empty");
|
||||
throw const AddressException("target mailbox name should not be empty");
|
||||
}
|
||||
if (localPartDetails.startsWith('#')) {
|
||||
throw AddressException("target mailbox name should not start with #");
|
||||
throw const AddressException("target mailbox name should not start with #");
|
||||
}
|
||||
final forbiddenChars = RegExp(r'[*\r\n]');
|
||||
if (forbiddenChars.hasMatch(localPartDetails)) {
|
||||
throw AddressException("target mailbox name should not contain special characters");
|
||||
throw const AddressException("target mailbox name should not contain special characters");
|
||||
}
|
||||
|
||||
localPartSB.write(localPartDetails);
|
||||
|
||||
Reference in New Issue
Block a user