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
@@ -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';
}
+11 -9
View File
@@ -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';
}