Exceptions: Python
Exception classes used throughout Guardrails for SDK and model errors.
GuardrailException
Bases: Exception
Base class for exceptions thrown by :mod:guardrails
.
Source code in src/guardrails/exceptions.py
6 7 |
|
UserError
Bases: GuardrailException
Error raised when the user misuses the SDK.
Source code in src/guardrails/exceptions.py
10 11 12 13 14 15 16 17 18 |
|
__init__
__init__(message: str)
Initialize the exception with a human readable message.
Source code in src/guardrails/exceptions.py
15 16 17 18 |
|
ModelBehaviorError
Bases: GuardrailException
Error raised when the model returns malformed or invalid data.
Source code in src/guardrails/exceptions.py
21 22 23 24 25 26 27 28 29 |
|
__init__
__init__(message: str)
Initialize with information on the misbehaviour.
Source code in src/guardrails/exceptions.py
26 27 28 29 |
|
GuardrailTripwireTriggered
Bases: GuardrailException
Raised when a guardrail triggers a configured tripwire.
Source code in src/guardrails/exceptions.py
32 33 34 35 36 37 38 39 40 41 42 43 |
|
guardrail_result
instance-attribute
guardrail_result: GuardrailResult = guardrail_result
The result data from the triggering guardrail.
__init__
__init__(guardrail_result: GuardrailResult)
Initialize storing the result which caused the tripwire.
Source code in src/guardrails/exceptions.py
38 39 40 41 42 43 |
|
ConfigError
Bases: GuardrailException
Configuration bundle could not be loaded or validated.
Source code in src/guardrails/exceptions.py
46 47 48 49 50 51 52 |
|
__init__
__init__(message: str)
Initialize with a short description of the failure.
Source code in src/guardrails/exceptions.py
49 50 51 52 |
|
ContextValidationError
Bases: GuardrailException
Raised when CLI context fails to match guardrail specification.
Source code in src/guardrails/exceptions.py
55 56 57 58 59 60 61 |
|
__init__
__init__(message: str)
Initialize with details about the schema mismatch.
Source code in src/guardrails/exceptions.py
58 59 60 61 |
|