class ApiException implements Exception { final String message; final int? statusCode; final List fieldErrors; const ApiException({ required this.message, this.statusCode, this.fieldErrors = const [], }); @override String toString() => 'ApiException: $message (status: $statusCode)'; } class FieldError { final String field; final List errors; const FieldError({required this.field, required this.errors}); factory FieldError.fromJson(Map json) { return FieldError( field: json['field'] as String? ?? '', errors: (json['errors'] as List?) ?.map((e) => e.toString()) .toList() ?? [], ); } }