Files
superport/lib/core/errors/exceptions.dart

134 lines
2.7 KiB
Dart

/// 커스텀 예외 클래스들 정의
library;
/// 서버 예외
class ServerException implements Exception {
final String message;
final int? statusCode;
final Map<String, dynamic>? errors;
ServerException({
required this.message,
this.statusCode,
this.errors,
});
@override
String toString() => 'ServerException: $message (code: $statusCode)';
}
/// 캐시 예외
class CacheException implements Exception {
final String message;
CacheException({required this.message});
@override
String toString() => 'CacheException: $message';
}
/// 네트워크 예외
class NetworkException implements Exception {
final String message;
NetworkException({required this.message});
@override
String toString() => 'NetworkException: $message';
}
/// 인증 예외
class UnauthorizedException implements Exception {
final String message;
UnauthorizedException({required this.message});
@override
String toString() => 'UnauthorizedException: $message';
}
/// 유효성 검사 예외
class ValidationException implements Exception {
final String message;
final Map<String, List<String>>? fieldErrors;
ValidationException({
required this.message,
this.fieldErrors,
});
@override
String toString() => 'ValidationException: $message';
}
/// 권한 부족 예외
class ForbiddenException implements Exception {
final String message;
ForbiddenException({required this.message});
@override
String toString() => 'ForbiddenException: $message';
}
/// 리소스 찾을 수 없음 예외
class NotFoundException implements Exception {
final String message;
final String? resourceType;
final String? resourceId;
NotFoundException({
required this.message,
this.resourceType,
this.resourceId,
});
@override
String toString() => 'NotFoundException: $message';
}
/// 중복 리소스 예외
class DuplicateException implements Exception {
final String message;
final String? field;
final String? value;
DuplicateException({
required this.message,
this.field,
this.value,
});
@override
String toString() => 'DuplicateException: $message';
}
/// 비즈니스 로직 예외
class BusinessException implements Exception {
final String message;
final String? code;
BusinessException({
required this.message,
this.code,
});
@override
String toString() => 'BusinessException: $message (code: $code)';
}
/// API 관련 예외
class ApiException implements Exception {
final String message;
final int? statusCode;
final Map<String, dynamic>? errors;
ApiException({
required this.message,
this.statusCode,
this.errors,
});
@override
String toString() => 'ApiException: $message (code: $statusCode)';
}