Skip to content

Commit

Permalink
Improved error message
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalii-bezuhlyi committed Jul 2, 2024
1 parent 2f9c257 commit bf6339c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Apps.XtrfCustomerPortal/Api/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,23 @@ protected override Exception ConfigureErrorException(RestResponse response)
using var xmlReader = new StringReader(response.Content!);

var xmlErrorDto = (XmlErrorDto)xmlSerializer.Deserialize(xmlReader)!;
return new Exception($"Error message: {xmlErrorDto.Body}; StatusCode: {response.StatusCode}");
return new Exception($"Error message: {xmlErrorDto.Body}; Status code: {response.StatusCode}");
}
catch (InvalidOperationException)
{
try
{
var jsonErrorDto = JsonConvert.DeserializeObject<JsonErrorDto>(response.Content!)!;
return new Exception($"Error message: {jsonErrorDto.ErrorMessage}; StatusCode: {response.StatusCode}");
return new Exception($"Error message: {jsonErrorDto.ErrorMessage}; Status code: {response.StatusCode}");
}
catch (JsonException)
{
return new Exception($"Error message: {response.Content}; StatusCode: {response.StatusCode}");
return new Exception($"Error message: {response.Content}; Status code: {response.StatusCode}");
}
}
catch (Exception ex)
{
return new Exception($"Unexpected error during error deserialization: {ex.Message}; Error body: {response.Content!} ; StatusCode: {response.StatusCode}");
return new Exception($"Unexpected error during error deserialization: {ex.Message}; Error body: {response.Content!} ; Status code: {response.StatusCode}");
}
}
}

0 comments on commit bf6339c

Please sign in to comment.