Skip to content

base

pyvider.cty.exceptions.base

TODO: Add module docstring.

Classes

CtyError

CtyError(
    message: str = "An error occurred in the cty type system",
    **kwargs: Any
)

Bases: FoundationError

Base exception for all pyvider.cty errors.

This is the root exception for all errors that occur within the cty type system. It provides a foundation for more specific error types and can be used to catch any cty-related error.

Now inherits from FoundationError to provide rich context support, telemetry integration, and enhanced diagnostics.

Attributes:

Name Type Description
message

A human-readable error description

Source code in pyvider/cty/exceptions/base.py
def __init__(self, message: str = "An error occurred in the cty type system", **kwargs: Any) -> None:
    self.message = message
    super().__init__(self.message, **kwargs)

CtyFunctionError

CtyFunctionError(
    message: str = "An error occurred during CTY function execution",
    *,
    function_name: str | None = None,
    input_types: list[str] | None = None,
    **kwargs: Any
)

Bases: CtyError

Exception raised for errors during the execution of a CTY standard library function.

Enhanced with rich context support for function name, arguments, and execution details.

Attributes:

Name Type Description
message

A human-readable error description

function_name

Name of the CTY function that failed

Source code in pyvider/cty/exceptions/base.py
def __init__(
    self,
    message: str = "An error occurred during CTY function execution",
    *,
    function_name: str | None = None,
    input_types: list[str] | None = None,
    **kwargs: Any,
) -> None:
    self.function_name = function_name
    self.input_types = input_types or []

    # Add function-specific context
    context: dict[str, Any] = kwargs.setdefault("context", {})
    context["cty.error_category"] = "function_execution"
    context["cty.operation"] = "cty_function"

    if function_name:
        context["cty.function_name"] = function_name

    if input_types:
        context["cty.function_input_types"] = input_types
        context["cty.function_arity"] = len(input_types)

    # Enhance message if function name available
    if function_name:
        message = f"CTY function '{function_name}' failed: {message}"

    super().__init__(message, **kwargs)