Skip to navigation

nemoguardrails.exceptions

View as MarkdownOpen in Claude

Module Contents

Classes

NameDescription
ConfigurationErrorBase class for Guardrails Configuration validation errors.
InvalidCheckRequestErrorRaised when a check’s arguments contradict each other, such as tools without a tool_call check.
InvalidModelConfigurationErrorRaised when a guardrail configuration’s model is invalid.
InvalidRailsConfigurationErrorRaised when rails configuration is invalid.
InvalidStateErrorRaised when a caller-supplied state argument is not valid public input.
LLMAuthenticationError-
LLMBadRequestError-
LLMCallExceptionA wrapper around the LLM call invocation exception.
LLMClientErrorBase class for LLM client errors.
LLMConnectionError-
LLMContextWindowError-
LLMRateLimitError-
LLMResponseValidationError-
LLMServerError-
LLMTimeoutError-
LLMUnsupportedParamsError-
NonStreamingWorkQueueFullErrorRaised when the IORails non-streaming admission queue cannot accept more work.
RailTypeNotConfiguredErrorRaised when an explicitly requested rail type has no configured flows.
RailTypeNotSupportedErrorRaised when an explicitly requested rail type cannot run on the serving engine.
StreamingCapacityExceededErrorRaised when IORails has no free streaming slot for a new request.
StreamingNotSupportedErrorRaised when streaming is requested but not supported by the configuration.
ToolConversationTooLongErrorRaised when a rendered tool conversation exceeds the general prompt limit.

API

class nemoguardrails.exceptions.ConfigurationError()

Bases: ValueError

Base class for Guardrails Configuration validation errors.

class nemoguardrails.exceptions.InvalidCheckRequestError()

Bases: ValueError

Raised when a check’s arguments contradict each other, such as tools without a tool_call check.

class nemoguardrails.exceptions.InvalidModelConfigurationError()

Bases: ConfigurationError

Raised when a guardrail configuration’s model is invalid.

class nemoguardrails.exceptions.InvalidRailsConfigurationError()

Bases: ConfigurationError

Raised when rails configuration is invalid.

Examples:

- Input/output rail references a model that doesn't exist in config
- Rail references a flow that doesn't exist
- Missing required prompt template
- Invalid rail parameters
class nemoguardrails.exceptions.InvalidStateError()

Bases: ValueError

Raised when a caller-supplied state argument is not valid public input.

The serialized Colang 2.0 runtime State carries trusted control-plane fields (flow_configs, rails_config, in-flight flow execution) and must not come from an untrusted caller. Stateful 2.x execution uses process_events_async, which keeps a live State object in the trusted Python process.

class nemoguardrails.exceptions.LLMAuthenticationError()
class nemoguardrails.exceptions.LLMBadRequestError()
class nemoguardrails.exceptions.LLMCallException(
inner_exception: typing.Union[BaseException, str],
detail: typing.Optional[str] = None,
status: typing.Optional[int] = None
)
Exception

Bases: Exception

A wrapper around the LLM call invocation exception.

This is used to propagate the exception out of the generate_async call. When the inner exception carries an HTTP status code (e.g. a LLMClientError), callers can inspect status to decide which HTTP response code to return to the upstream client.

class nemoguardrails.exceptions.LLMClientError(
status_code: int,
error_message: str,
error_type: typing.Optional[str] = None,
error_code: typing.Optional[str] = None,
param: typing.Optional[str] = None,
body: typing.Optional[dict] = None,
response_headers: typing.Optional[dict] = None,
model_name: typing.Optional[str] = None,
provider_name: typing.Optional[str] = None,
base_url: typing.Optional[str] = None
)
Exception

Bases: Exception

Base class for LLM client errors.

status_code holds the HTTP response status when one was received, or 0 when no response arrived (client-side timeout or network error). Callers should branch on exception class rather than status_code to distinguish HTTP vs network failures, the type hierarchy is the authoritative discriminator.

nemoguardrails.exceptions.LLMClientError.__str__() -> str
class nemoguardrails.exceptions.LLMConnectionError()
class nemoguardrails.exceptions.LLMContextWindowError()
class nemoguardrails.exceptions.LLMRateLimitError(
status_code: int,
error_message: str,
error_type: typing.Optional[str] = None,
error_code: typing.Optional[str] = None,
param: typing.Optional[str] = None,
body: typing.Optional[dict] = None,
response_headers: typing.Optional[dict] = None,
model_name: typing.Optional[str] = None,
provider_name: typing.Optional[str] = None,
base_url: typing.Optional[str] = None,
retry_after_seconds: typing.Optional[float] = None
)
class nemoguardrails.exceptions.LLMResponseValidationError(
message: str,
response_data: typing.Optional[dict] = None,
model_name: typing.Optional[str] = None,
provider_name: typing.Optional[str] = None,
base_url: typing.Optional[str] = None
)
class nemoguardrails.exceptions.LLMServerError()
class nemoguardrails.exceptions.LLMTimeoutError()
class nemoguardrails.exceptions.LLMUnsupportedParamsError()
class nemoguardrails.exceptions.NonStreamingWorkQueueFullError()

Bases: QueueFull

Raised when the IORails non-streaming admission queue cannot accept more work.

Subclasses asyncio.QueueFull because that is what the underlying work queue raises, so callers already catching it keep working.

class nemoguardrails.exceptions.RailTypeNotConfiguredError()

Bases: InvalidRailsConfigurationError

Raised when an explicitly requested rail type has no configured flows.

class nemoguardrails.exceptions.RailTypeNotSupportedError()

Bases: InvalidRailsConfigurationError

Raised when an explicitly requested rail type cannot run on the serving engine.

class nemoguardrails.exceptions.StreamingCapacityExceededError()
Exception

Bases: Exception

Raised when IORails has no free streaming slot for a new request.

The streaming path is bounded by an asyncio.Semaphore rather than a queue, so this deliberately does not subclass asyncio.QueueFull: nothing is queued and nothing is full. It is a distinct overload condition from NonStreamingWorkQueueFullError and carries its own client-facing message.

class nemoguardrails.exceptions.StreamingNotSupportedError()

Bases: InvalidRailsConfigurationError

Raised when streaming is requested but not supported by the configuration.

class nemoguardrails.exceptions.ToolConversationTooLongError(
actual_length: int,
max_length: int
)

Bases: ValueError

Raised when a rendered tool conversation exceeds the general prompt limit.

Tool exchanges are rejected intact rather than truncated, which could orphan calls or discard the results needed to answer the user. Lengths are measured in serialized characters, with structured inline image payloads discounted.