Skip to content

Commit

Permalink
Merge pull request #103 from pkuehnel/feat/loggingGetOverage
Browse files Browse the repository at this point in the history
feat(GridService): log requestUri and error reason phrase
  • Loading branch information
pkuehnel authored Apr 26, 2022
2 parents d0d29c8 + 12c438f commit 019ff6d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion SmartTeslaAmpSetter/Server/Services/GridService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ public async Task<int> GetCurrentOverage()
_logger.LogTrace("{method}()", nameof(GetCurrentOverage));
using var httpClient = new HttpClient();
var requestUri = _configuration.GetValue<string>("CurrentPowerToGridUrl");
_logger.LogDebug("Using {uri} to get current overage.", requestUri);
var response = await httpClient.GetAsync(
requestUri)
.ConfigureAwait(false);
response.EnsureSuccessStatusCode();

if (!response.IsSuccessStatusCode)
{
_logger.LogError("Could not get current overage. {statusCode}, {reasonPhrase}", response.StatusCode, response.ReasonPhrase);
response.EnsureSuccessStatusCode();
}

var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

var jsonPattern = _configuration.GetValue<string>("CurrentPowerToGridJsonPattern");
Expand Down

0 comments on commit 019ff6d

Please sign in to comment.