Refactoring - Version OK
This commit is contained in:
50
unionflow-mobile-apps/lib/core/error/exceptions.dart
Normal file
50
unionflow-mobile-apps/lib/core/error/exceptions.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
/// Exception de base pour l'application
|
||||
abstract class AppException implements Exception {
|
||||
final String message;
|
||||
final String? code;
|
||||
|
||||
const AppException(this.message, [this.code]);
|
||||
|
||||
@override
|
||||
String toString() => 'AppException: $message${code != null ? ' (Code: $code)' : ''}';
|
||||
}
|
||||
|
||||
/// Exception serveur
|
||||
class ServerException extends AppException {
|
||||
const ServerException(super.message, [super.code]);
|
||||
|
||||
@override
|
||||
String toString() => 'ServerException: $message${code != null ? ' (Code: $code)' : ''}';
|
||||
}
|
||||
|
||||
/// Exception de cache
|
||||
class CacheException extends AppException {
|
||||
const CacheException(super.message, [super.code]);
|
||||
|
||||
@override
|
||||
String toString() => 'CacheException: $message${code != null ? ' (Code: $code)' : ''}';
|
||||
}
|
||||
|
||||
/// Exception de réseau
|
||||
class NetworkException extends AppException {
|
||||
const NetworkException(super.message, [super.code]);
|
||||
|
||||
@override
|
||||
String toString() => 'NetworkException: $message${code != null ? ' (Code: $code)' : ''}';
|
||||
}
|
||||
|
||||
/// Exception d'authentification
|
||||
class AuthException extends AppException {
|
||||
const AuthException(super.message, [super.code]);
|
||||
|
||||
@override
|
||||
String toString() => 'AuthException: $message${code != null ? ' (Code: $code)' : ''}';
|
||||
}
|
||||
|
||||
/// Exception de validation
|
||||
class ValidationException extends AppException {
|
||||
const ValidationException(super.message, [super.code]);
|
||||
|
||||
@override
|
||||
String toString() => 'ValidationException: $message${code != null ? ' (Code: $code)' : ''}';
|
||||
}
|
||||
Reference in New Issue
Block a user