[pve-devel] [PATCH dart_api_client 1/1] fix #4976: Request errors are
Alexander Abraham
a.abraham at proxmox.com
Tue Apr 29 15:16:44 CEST 2025
This commit adds more explicit error-handling for when a host
is possibly offline.
Signed-off-by: Alexander Abraham <a.abraham at proxmox.com>
---
lib/src/client.dart | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/src/client.dart b/lib/src/client.dart
index f597c28..7c118d8 100644
--- a/lib/src/client.dart
+++ b/lib/src/client.dart
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'dart:io';
-
import 'package:http/http.dart' as http;
//import 'package:proxmox_dart_api_client/src/models/pve_access_user_model.dart';
import 'package:proxmox_dart_api_client/src/models/pve_models.dart';
@@ -127,7 +126,7 @@ class ProxmoxApiClient extends http.BaseClient {
() => get(url),
retryIf: (e) => e is http.ClientException || e is SocketException,
))
- .validate(extensiveResponseValidation);
+ .validate(extensiveResponseValidation);
}
Future<http.Response> _postWithValidation(
@@ -398,9 +397,14 @@ class ProxmoxApiClient extends http.BaseClient {
'typefilter': typefilter,
'userfilter': userfilter
};
- final response = await _getWithValidation(path, queryParameters);
+ var response;
+ try {
+ response = await _getWithValidation(path, queryParameters);
+ }
+ catch(e) {
+ throw "Host unreachable, possibly offline.";
+ }
final decoded = json.decode(response.body);
-
var data = (decoded['data'] as List).map((f) {
return serializers.deserializeWith(PveClusterTasksModel.serializer, f);
});
@@ -563,7 +567,7 @@ class ProxmoxApiClient extends http.BaseClient {
var data = (json.decode(response.body)['data'] as List).map((f) {
return serializers.deserializeWith(PveNodeRRDDataModel.serializer, f);
});
- return data.whereType<PveNodeRRDDataModel>().toList();
+ return data.whereType<PveNodeRRDDataModel>().toList();
}
Future<List<PveNodeServicesModel>> getNodeServices(
--
2.39.5
More information about the pve-devel
mailing list