38 lines
967 B
Dart
38 lines
967 B
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'failure.freezed.dart';
|
|
|
|
@freezed
|
|
class Failure with _$Failure {
|
|
const factory Failure.server({
|
|
required String message,
|
|
String? code,
|
|
int? statusCode,
|
|
}) = ServerFailure;
|
|
|
|
const factory Failure.network({
|
|
@Default('No internet connection') String message,
|
|
}) = NetworkFailure;
|
|
|
|
const factory Failure.unauthorized({
|
|
@Default('Session expired. Please login again.') String message,
|
|
}) = UnauthorizedFailure;
|
|
|
|
const factory Failure.validation({
|
|
required String message,
|
|
Map<String, List<String>>? errors,
|
|
}) = ValidationFailure;
|
|
|
|
const factory Failure.notFound({
|
|
@Default('Resource not found') String message,
|
|
}) = NotFoundFailure;
|
|
|
|
const factory Failure.cache({
|
|
@Default('Cache error') String message,
|
|
}) = CacheFailure;
|
|
|
|
const factory Failure.unknown({
|
|
@Default('An unexpected error occurred') String message,
|
|
}) = UnknownFailure;
|
|
}
|