Skip to content

Commit

Permalink
Add some error info
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Sep 13, 2024
1 parent 9c40584 commit 2d42baa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions IssueVerifiableEmployee/Services/IssuerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<ActionResult> IssuanceRequestAsync()
var (Token, Error, ErrorDescription) = await _issuerService.GetAccessToken();
if (string.IsNullOrEmpty(Token))
{
_log.LogError("failed to acquire accesstoken: {Error} : {ErrorDescription}", Error, ErrorDescription);
_log.LogError("failed to acquire access token: {Error} : {ErrorDescription}", Error, ErrorDescription);
return BadRequest(new { error = Error, error_description = ErrorDescription });
}

Expand All @@ -58,7 +58,12 @@ public async Task<ActionResult> IssuanceRequestAsync()

var res = await _httpClient.PostAsJsonAsync(_credentialSettings.Endpoint, payload);

//var test = await res.Content.ReadAsStringAsync();
if(!res.IsSuccessStatusCode)
{
var test = await res.Content.ReadAsStringAsync();
_log.LogError("failed to acquire access token: {Error}", test);
}

var response = await res.Content.ReadFromJsonAsync<IssuanceResponse>();

if (response == null)
Expand All @@ -68,7 +73,7 @@ public async Task<ActionResult> IssuanceRequestAsync()

if (res.StatusCode == HttpStatusCode.Created)
{
_log.LogTrace("succesfully called Request API");
_log.LogTrace("successfully called Request API");

if (payload.Pin.Value != null)
{
Expand All @@ -91,7 +96,7 @@ public async Task<ActionResult> IssuanceRequestAsync()
{
var message = await res.Content.ReadAsStringAsync();

_log.LogError("Unsuccesfully called Request API {message}", message);
_log.LogError("Unsuccessfully called Request API {message}", message);
return BadRequest(new { error = "400", error_description = "Something went wrong calling the API: " + response });
}
}
Expand Down

0 comments on commit 2d42baa

Please sign in to comment.