// Copyright (c) Microsoft. All rights reserved.
using System.Collections;
using ContentSafety.Services.PromptShield;
namespace ContentSafety.Exceptions;
///
/// Exception which is thrown when attack is detected in user prompt or documents.
/// More information here: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-jailbreak#interpret-the-api-response
///
public class AttackDetectionException : Exception
{
///
/// Contains analysis result for the user prompt.
///
public PromptShieldAnalysis? UserPromptAnalysis { get; init; }
///
/// Contains a list of analysis results for each document provided.
///
public IReadOnlyList? DocumentsAnalysis { get; init; }
///
/// Dictionary with additional details of exception.
///
public override IDictionary Data => new Dictionary()
{
["userPrompt"] = this.UserPromptAnalysis,
["documents"] = this.DocumentsAnalysis,
};
public AttackDetectionException()
{
}
public AttackDetectionException(string? message) : base(message)
{
}
public AttackDetectionException(string? message, Exception? innerException) : base(message, innerException)
{
}
}