[pve-devel] [PATCH dart_api_client 1/1] fix #4976: Request errors are
Michael Köppl
m.koeppl at proxmox.com
Mon May 5 15:03:53 CEST 2025
On 5/2/25 12:19, Michael Köppl wrote:
> Hi, thanks for tackling this. Noticed a few small things. Find the
> comments inline. Generally, please run dart format on these changes.
> Every changed block contains wrong indentation. Also, the commit message
> needs to be fixed.
>
> On 4/29/25 15:16, Alexander Abraham wrote:
>> 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.";
>
> Is there a reason this is not wrapped in a ProxmoxApiException? If the
> reason is that it then displays "Host unreachable, possibly offline. ->
> null", I think it would generally be a good idea to adapt
> ProxmoxApiException's toString method to account for the details
> possibly being null.
Just wanted to add that I sent a patch for adapting
ProxmoxApiException's toString method since I encountered this problem
elsewhere as well:
https://lore.proxmox.com/pve-devel/20250505072845.28299-1-m.koeppl@proxmox.com/T/#u
More information about the pve-devel
mailing list