초기 커밋
This commit is contained in:
39
lib/core/error/exceptions.dart
Normal file
39
lib/core/error/exceptions.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
class ServerException implements Exception {
|
||||
const ServerException({
|
||||
required this.message,
|
||||
required this.statusCode,
|
||||
});
|
||||
|
||||
final String message;
|
||||
final int statusCode;
|
||||
|
||||
@override
|
||||
String toString() => 'ServerException(message: $message, statusCode: $statusCode)';
|
||||
}
|
||||
|
||||
class CacheException implements Exception {
|
||||
const CacheException({required this.message});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => 'CacheException(message: $message)';
|
||||
}
|
||||
|
||||
class NetworkException implements Exception {
|
||||
const NetworkException({this.message = 'No internet connection'});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => 'NetworkException(message: $message)';
|
||||
}
|
||||
|
||||
class UnauthorizedException implements Exception {
|
||||
const UnauthorizedException({this.message = 'Unauthorized'});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => 'UnauthorizedException(message: $message)';
|
||||
}
|
||||
27
lib/core/error/failures.dart
Normal file
27
lib/core/error/failures.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'failures.freezed.dart';
|
||||
|
||||
@freezed
|
||||
sealed class Failure with _$Failure {
|
||||
const factory Failure.server({
|
||||
required String message,
|
||||
@Default(500) int statusCode,
|
||||
}) = ServerFailure;
|
||||
|
||||
const factory Failure.cache({
|
||||
required String message,
|
||||
}) = CacheFailure;
|
||||
|
||||
const factory Failure.network({
|
||||
@Default('네트워크 연결을 확인해주세요') String message,
|
||||
}) = NetworkFailure;
|
||||
|
||||
const factory Failure.unauthorized({
|
||||
@Default('인증이 필요합니다') String message,
|
||||
}) = UnauthorizedFailure;
|
||||
|
||||
const factory Failure.unknown({
|
||||
@Default('알 수 없는 오류가 발생했습니다') String message,
|
||||
}) = UnknownFailure;
|
||||
}
|
||||
Reference in New Issue
Block a user