import 'package:equatable/equatable.dart';

/// Base class for all failures in the application
/// Failures represent errors that can be handled gracefully
abstract class Failure extends Equatable {
  final String message;

  const Failure(this.message);

  @override
  List<Object> get props => [message];
}

/// Failure that occurs when there's a server-related error
/// This includes HTTP errors, API errors, etc.
class ServerFailure extends Failure {
  const ServerFailure(super.message);

  @override
  String toString() => 'ServerFailure: $message';
}

/// Failure that occurs when there's a network-related error
/// This includes connection timeouts, no internet, etc.
class NetworkFailure extends Failure {
  const NetworkFailure(super.message);

  @override
  String toString() => 'NetworkFailure: $message';
}

/// Failure that occurs when there's a local storage error
/// This includes cache errors, database errors, etc.
class CacheFailure extends Failure {
  const CacheFailure(super.message);

  @override
  String toString() => 'CacheFailure: $message';
}

/// Failure that occurs during authentication
/// This includes login failures, invalid credentials, expired tokens, etc.
class AuthenticationFailure extends Failure {
  const AuthenticationFailure(super.message);

  @override
  String toString() => 'AuthenticationFailure: $message';
}

/// Failure that occurs when input validation fails
class ValidationFailure extends Failure {
  const ValidationFailure(super.message);

  @override
  String toString() => 'ValidationFailure: $message';
}

/// Failure that occurs when a required permission is denied
class PermissionFailure extends Failure {
  const PermissionFailure(super.message);

  @override
  String toString() => 'PermissionFailure: $message';
}

/// Failure that occurs when scanning operation fails
class ScannerFailure extends Failure {
  const ScannerFailure(super.message);

  @override
  String toString() => 'ScannerFailure: $message';
}

/// Failure that occurs when printing operation fails
class PrintFailure extends Failure {
  const PrintFailure(super.message);

  @override
  String toString() => 'PrintFailure: $message';
}

/// Generic failure for unexpected errors
class UnknownFailure extends Failure {
  const UnknownFailure([super.message = 'An unexpected error occurred']);

  @override
  String toString() => 'UnknownFailure: $message';
}