feat: Implement initial authentication, multi-environment support, and core app infrastructure.
This commit is contained in:
31
lib/core/network/api_exceptions.dart
Normal file
31
lib/core/network/api_exceptions.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class ApiException implements Exception {
|
||||
final String message;
|
||||
final int? statusCode;
|
||||
final List<FieldError> 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<String> errors;
|
||||
|
||||
const FieldError({required this.field, required this.errors});
|
||||
|
||||
factory FieldError.fromJson(Map<String, dynamic> json) {
|
||||
return FieldError(
|
||||
field: json['field'] as String? ?? '',
|
||||
errors: (json['errors'] as List<dynamic>?)
|
||||
?.map((e) => e.toString())
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user