import 'package:equatable/equatable.dart';

/// Classe de base pour tous les échecs
abstract class Failure extends Equatable {
  final String message;
  final String? code;

  const Failure(this.message, [this.code]);

  @override
  List<Object?> get props => [message, code];

  @override
  String toString() => 'Failure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec serveur
class ServerFailure extends Failure {
  const ServerFailure(super.message, [super.code]);

  @override
  String toString() => 'ServerFailure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec de cache
class CacheFailure extends Failure {
  const CacheFailure(super.message, [super.code]);

  @override
  String toString() => 'CacheFailure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec de réseau
class NetworkFailure extends Failure {
  const NetworkFailure(super.message, [super.code]);

  @override
  String toString() => 'NetworkFailure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec d'authentification
class AuthFailure extends Failure {
  const AuthFailure(super.message, [super.code]);

  @override
  String toString() => 'AuthFailure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec de validation
class ValidationFailure extends Failure {
  const ValidationFailure(super.message, [super.code]);

  @override
  String toString() => 'ValidationFailure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec de permission
class PermissionFailure extends Failure {
  const PermissionFailure(super.message, [super.code]);

  @override
  String toString() => 'PermissionFailure: $message${code != null ? ' (Code: $code)' : ''}';
}

/// Échec de données non trouvées
class NotFoundFailure extends Failure {
  const NotFoundFailure(super.message, [super.code]);

  @override
  String toString() => 'NotFoundFailure: $message${code != null ? ' (Code: $code)' : ''}';
}
