From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 2A5021FF16F
	for <inbox@lore.proxmox.com>; Tue, 29 Apr 2025 15:17:26 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 36136E029;
	Tue, 29 Apr 2025 15:17:35 +0200 (CEST)
From: Alexander Abraham <a.abraham@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Tue, 29 Apr 2025 15:16:44 +0200
Message-Id: <20250429131645.106612-2-a.abraham@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250429131645.106612-1-a.abraham@proxmox.com>
References: <20250429131645.106612-1-a.abraham@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.039 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 POISEN_SPAM_PILL          0.1 Meta: its spam
 POISEN_SPAM_PILL_2        0.1 random spam to be learned in bayes
 POISEN_SPAM_PILL_4        0.1 random spam to be learned in bayes
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH dart_api_client 1/1] fix #4976: Request errors
 are
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

This commit adds more explicit error-handling for when a host
is possibly offline.

Signed-off-by: Alexander Abraham <a.abraham@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel