I'm trying to get create an 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?
To give you context to how it will work:
if (isProfanity)
{
throw new RemoteException("The username contains profanity. Please pick a different one.",
"The username contains profanity and has been denied.",
RemoteExceptionType.ProfileUsernameProfanityException);
}
else if (warning)
{
var log = new ProfanityAuditLog
{
Username = text,
DetectedLanguage = detectedLanguage.DetectedLanguageProperty,
IsProfanity = isProfanity,
ThresholdCategory1 = _options.ThresholdCategory1,
ThresholdCategory2 = _options.ThresholdCategory2,
ThresholdCategory3 = _options.ThresholdCategory3,
//ExceptionMessage = exception
};
_profanityAuditRepo.AddLogAsync(log);
throw new RemoteException("The username might contain profanity.",
"The username might contain profanity and will have to be validated by support.",
RemoteExceptionType.ProfileUsernameProfanityWarningException);
}
If the word is profanity the remote exception should be thrown and the word should be considered profanity, if the word falls between the ratio of 0.5
& 0.7
the word should be categorized as a warning and be added to the AuditLog
for user validation and a emote exception should be thrown to tell the user. The issue is the Exception Message I am referring to in the log
needs to be the exception I receive from Azure
, this is in case the issue is related to Azure
and not the word e.g. API service is down.
This is what I got from some forums and Googling but it's not exactly what I am looking for.
string exceptionMessage = screen?.Classification.ReviewRecommended? "Azure review recommended": "Custom warning message"