refactor: cambio las respuestas de error para no culpar al usuario al fallar la deserializacion sino como una ApiException
This commit is contained in:
parent
572547b356
commit
198fccd5bc
|
|
@ -48,7 +48,7 @@ public class DolibarrApiClient
|
|||
await HandleErrorsAsync(response, endpoint);
|
||||
|
||||
return await response.Content.ReadFromJsonAsync<T>()
|
||||
?? throw new BadRequestException("Failed to deserialize response");
|
||||
?? throw new ApiException($"Failed to deserialize response from Dolibarr for endpoint '{endpoint}'");
|
||||
}
|
||||
|
||||
private async Task<List<T>> GetListAsync<T>(string endpoint) where T : class
|
||||
|
|
@ -56,7 +56,9 @@ public class DolibarrApiClient
|
|||
var response = await _httpClient.GetAsync(endpoint);
|
||||
await HandleErrorsAsync(response, endpoint);
|
||||
|
||||
return await response.Content.ReadFromJsonAsync<List<T>>() ?? new List<T>();
|
||||
return await response.Content.ReadFromJsonAsync<List<T>>()
|
||||
?? throw new ApiException(
|
||||
$"Failed to deserialize list response from Dolibarr for endpoint '{endpoint}'");
|
||||
}
|
||||
|
||||
private async Task HandleErrorsAsync(HttpResponseMessage response, string endpoint)
|
||||
|
|
|
|||
Loading…
Reference in New Issue