Skip to content

Commit

Permalink
Update CoinApiRestClient.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Svisstack authored Apr 23, 2024
1 parent e7c2510 commit 00848de
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion data-api/csharp-rest/CoinAPI.REST.V1/CoinApiRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ private async Task<T> GetData<T>(string url)

private static async Task RaiseError(HttpResponseMessage response)
{
var message = (await Deserialize<ErrorMessage>(response).ConfigureAwait(false)).message;
var responseString = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);

Check failure on line 63 in data-api/csharp-rest/CoinAPI.REST.V1/CoinApiRestClient.cs

View workflow job for this annotation

GitHub Actions / publish

The name 'responseMessage' does not exist in the current context

Check failure on line 63 in data-api/csharp-rest/CoinAPI.REST.V1/CoinApiRestClient.cs

View workflow job for this annotation

GitHub Actions / publish

The name 'responseMessage' does not exist in the current context
var message = (await DeserializeFromString<ErrorMessage>(responseString).ConfigureAwait(false))?.message ?? responseString;

switch ((int)response.StatusCode)
{
Expand All @@ -79,6 +80,12 @@ private static async Task RaiseError(HttpResponseMessage response)
}
}

private static async Task<T> DeserializeFromString<T>(string responseString)

Check warning on line 83 in data-api/csharp-rest/CoinAPI.REST.V1/CoinApiRestClient.cs

View workflow job for this annotation

GitHub Actions / publish

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 83 in data-api/csharp-rest/CoinAPI.REST.V1/CoinApiRestClient.cs

View workflow job for this annotation

GitHub Actions / publish

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var data = JsonConvert.DeserializeObject<T>(responseString);
return data;
}

private static async Task<T> Deserialize<T>(HttpResponseMessage responseMessage)
{
var responseString = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
Expand Down

0 comments on commit 00848de

Please sign in to comment.