Skip to content

Commit

Permalink
Merge pull request #233 from pticostaricags/development
Browse files Browse the repository at this point in the history
Adding exception handling and logging error
  • Loading branch information
efonsecab authored Nov 19, 2024
2 parents 45f6b5b + 7aac95c commit 7c7f559
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,16 @@ public enum ArticleMood
}, cancellationToken: cancellationToken);
var contentResponse = response.Value.Content[0].Text;
logger.LogInformation("Content Response: {ContentResponse}", contentResponse);
TranslationResponse? translationResponse =
TranslationResponse? translationResponse=null;
try
{
translationResponse =
JsonSerializer.Deserialize<TranslationResponse>(contentResponse!);
}
catch (Exception ex)
{
logger.LogError(ex, "Error Translating. Source: {SourceText}. Response: {Response}. Exception: {Message}", translationRequest.OriginalText, response.Value.Content[0].Text, ex.Message);
}
return translationResponse;
}

Expand Down

0 comments on commit 7c7f559

Please sign in to comment.