Implement tender workflows and dashboard integration
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/push Build encountered an error
This commit is contained in:
@@ -179,7 +179,16 @@ class NetworkManager {
|
||||
/// Handle HTTP error responses
|
||||
Result<T> _handleHttpError<T>(Response response) {
|
||||
final statusCode = response.statusCode;
|
||||
final message = _extractErrorMessage(response.data);
|
||||
var message = _extractErrorMessage(response.data);
|
||||
if (statusCode == 422 && response.data is Map<String, dynamic>) {
|
||||
final envelope = response.data as Map<String, dynamic>;
|
||||
final error = envelope['error'];
|
||||
if (error is Map<String, dynamic> &&
|
||||
error['details'] is String &&
|
||||
(error['details'] as String).isNotEmpty) {
|
||||
message = error['details'] as String;
|
||||
}
|
||||
}
|
||||
|
||||
switch (statusCode) {
|
||||
case 400:
|
||||
@@ -238,16 +247,10 @@ class NetworkManager {
|
||||
);
|
||||
|
||||
case DioExceptionType.badResponse:
|
||||
if (e.response?.statusCode == 401) {
|
||||
// Handle token refresh logic here if needed
|
||||
// For now, return authentication error
|
||||
return Result.error(
|
||||
AuthenticationException(
|
||||
'Authentication failed',
|
||||
e.response?.statusCode,
|
||||
e,
|
||||
),
|
||||
);
|
||||
if (e.response != null) {
|
||||
// Preserve the backend envelope (including validation details) for
|
||||
// non-2xx responses such as 409 and 422.
|
||||
return _handleHttpError(e.response!);
|
||||
}
|
||||
return Result.error(
|
||||
FetchDataException(
|
||||
|
||||
Reference in New Issue
Block a user