Error Handling Azure Content Moderation API

Reinhardt Erasmus 5 Reputation points
2023-08-10T12:25:53.9233333+00:00

I'm trying to get create a AuditLog for my moderated content and would like to add the Exception Message sent by the Azure Content Moderation API to the log. Can anyone assist me with regards to saving this to a variable?

This is what I got from some forum and googling but its not exactly what I am looking for.

string exceptionMessage = screen?.Classification.ReviewRecommended ? "Azure review recommended" : "Custom warning message"; // Adjust this as needed based on Azure's response.

Community Center | Not monitored
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 48,906 Reputation points Microsoft Employee Moderator
    2023-08-11T08:31:58.6+00:00

    I think in the case where the service could be down there will be an error message from the moderation API and there would be no JSON to check the profanity score, so I think in this case you can add the response received as request failed to your audit log.

    For the scenario where the exception needs be differentiated, I do not see a configuration setting that could help to differentiate them based on the profanity score. I think client-side processing needs to be done to segregate the same.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.