refactor(sentry): standardize exceptions to prevent Sentry minification
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user