The errors.py module#

Summary#

FluidsMCPError

Base class for typed errors raised by leaves and backends.

BackendUnavailableError

Raised when a backend call fails because the backend is unavailable.

NotConnectedError

Raised when a backend call fails because the backend is not connected.

InvalidArgumentsError

Raised when a backend call fails due to invalid arguments.

UpstreamError

Raised when a backend call fails due to an upstream error (for example, a network issue).

DiscoveryError

Raised when a backend discovery operation fails.

typed_guard

Wrap an async tool handler so unexpected exceptions become TypedError.

T

Description#

Helper module to handle errors.

Typed error helpers and a guard decorator that converts 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.fluent.mcp.common.models.TypedError]]#

Wrap an async tool handler so unexpected exceptions become TypedError.

FluidsMCPError subclasses are converted to their typed form. Anything else is logged and wrapped as internal_error.

Parameters:
funcCallable[…, Awaitable[T]]

Function supplied to the decorator.

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

Result produced by the function.

errors.T#
errors.logger#