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/mendguardrails/exceptions.py
6 7 | |
UserError
Bases: GuardrailException
Error raised when the user misuses the SDK.
Source code in src/mendguardrails/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/mendguardrails/exceptions.py
15 16 17 18 | |
ModelBehaviorError
Bases: GuardrailException
Error raised when the model returns malformed or invalid data.
Source code in src/mendguardrails/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/mendguardrails/exceptions.py
26 27 28 29 | |
GuardrailEnforcementTriggered
Bases: GuardrailException
Raised when a guardrail triggers enforcement.
Source code in src/mendguardrails/exceptions.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
guardrail_result
instance-attribute
guardrail_result: GuardrailResult = guardrail_result
The result data from the triggering guardrail.
guardrail_name
property
guardrail_name: str
Registered name of the guardrail that triggered enforcement.
__init__
__init__(guardrail_result: GuardrailResult)
Initialize storing the result which caused the enforcement.
Source code in src/mendguardrails/exceptions.py
52 53 54 55 56 57 | |
ConfigError
Bases: GuardrailException
Configuration bundle could not be loaded or validated.
Source code in src/mendguardrails/exceptions.py
65 66 67 68 69 70 71 | |
__init__
__init__(message: str)
Initialize with a short description of the failure.
Source code in src/mendguardrails/exceptions.py
68 69 70 71 | |
ContextValidationError
Bases: GuardrailException
Raised when CLI context fails to match guardrail specification.
Source code in src/mendguardrails/exceptions.py
74 75 76 77 78 79 80 | |
__init__
__init__(message: str)
Initialize with details about the schema mismatch.
Source code in src/mendguardrails/exceptions.py
77 78 79 80 | |