Files
recipe-app/flutter/lib/core/api/api_exception.dart
T

26 lines
487 B
Dart

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';
}
}