enum ApiErrorType { unauthorized, forbidden, server, network, unknown, } class ApiException implements Exception { final ApiErrorType type; final int? statusCode; final String message; const ApiException({ required this.type, required this.message, this.statusCode, }); @override String toString() { final status = statusCode == null ? '' : ' (HTTP $statusCode)'; return 'ApiException$type$status: $message'; } }