SafetyViolationException

Exceptions · AiDotNet.Safety

Exception thrown when content fails a safety check and the configuration requires throwing.

Inheritance: Exception → SystemException → InvalidOperationException → SafetyViolationException

For Beginners

When the safety system finds dangerous content and is configured to throw exceptions, this is the exception you’ll catch. It contains the full SafetyReport with details about what was found.

How It Works

This exception is thrown when ThrowOnUnsafeInput or ThrowOnUnsafeOutput is true and the safety pipeline detects content that should be blocked.

Constructors

Constructor Summary
SafetyViolationException(SafetyReport report, bool isInputViolation) Initializes a new instance of the SafetyViolationException class.

Properties

Property Summary
SafetyReport Report { get; } Gets the safety report containing all findings.
bool IsInputViolation { get; } Gets whether this violation was on input (true) or output (false).