The errors.py module#

Summary#

FluidsMCPError

Base class for typed errors raised by leaves and backends.

BackendUnavailableError

Error raised when the requested backend cannot be used.

NotConnectedError

Error raised when an operation requires an active connection.

InvalidArgumentsError

Error raised when a tool receives invalid arguments.

UpstreamError

Error raised when an upstream CFX or provider call fails.

DiscoveryError

Error raised when API or model discovery fails.

typed_guard

Wrap an MCP tool so domain errors are returned as typed payloads.

T

Description#

Typed error helpers and typed-guard helpers.

Convert unexpected exceptions into a TypedError instead of crashing the MCP transport.

Module detail#

errors.typed_guard(func: Callable[Ellipsis, Awaitable[T]]) Callable[Ellipsis, Awaitable[T | ansys.cfx.mcp.common.models.TypedError]]#

Wrap an MCP tool so domain errors are returned as typed payloads.

Parameters:
funcCallable[…, Awaitable[T]]

Callable being wrapped or invoked.

Returns:
Callable[…, Awaitable[T | TypedError]]

Value computed by the helper for the requested CFX workflow.

errors.T#
errors.logger#
errors.BackendUnavailable#
errors.NotConnected#
errors.InvalidArguments#