feat: implement API client with JSON handling and error mapping; enhance routing and state management in app shell
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user