Added logic to remove supported languages that are no longer supported, rather than just being purely additive. Added ApiClient logging.
This commit is contained in:
@@ -22,8 +22,21 @@ public abstract class ApiClient(HttpClient http, ILogger logger, JsonSerializerO
|
||||
|
||||
Stream stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return await JsonSerializer.DeserializeAsync<TResponse>(stream, json, cancellationToken).ConfigureAwait(false)
|
||||
?? throw new InvalidOperationException($"Failed to deserialize JSON to {typeof(TResponse).Name} from {url}.");
|
||||
try
|
||||
{
|
||||
return await JsonSerializer.DeserializeAsync<TResponse>(stream, json, cancellationToken).ConfigureAwait(false)
|
||||
?? throw new InvalidOperationException($"Failed to deserialize JSON to {typeof(TResponse).Name} from {url}.");
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
logger.LogError(ex,
|
||||
"Failed to deserialize JSON from {Url}. ContentLengthHeader={ContentLengthHeader}",
|
||||
url,
|
||||
response.Content.Headers.ContentLength);
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected async Task<TResponse> GetJsonpAsync<TResponse>(
|
||||
|
||||
Reference in New Issue
Block a user