Skip to main content

portia.errors

Central definition of error classes.

This module defines custom exception classes used throughout the application. These exceptions help identify specific error conditions, particularly related to configuration, planning, runs, tools, and storage. They provide more context and clarity than generic exceptions.

Classes in this file include:

  • ConfigNotFoundError: Raised when a required configuration value is not found.
  • InvalidConfigError: Raised when a configuration value is invalid.
  • PlanError: A base class for exceptions in the query planning_agent module.
  • PlanNotFoundError: Raised when a plan is not found.
  • PlanRunNotFoundError: Raised when a PlanRun is not found.
  • ToolNotFoundError: Raised when a tool is not found.
  • DuplicateToolError: Raised when a tool is registered with the same name.
  • InvalidToolDescriptionError: Raised when a tool description is invalid.
  • ToolRetryError: Raised when a tool fails after retries.
  • ToolFailedError: Raised when a tool fails with a hard error.
  • InvalidConfigError0: Raised when a plan run is in an invalid state.
  • InvalidConfigError1: Raised when the agent produces invalid output.
  • InvalidConfigError2: Raised when a tool encounters an unrecoverable error.
  • InvalidConfigError3: Raised when a tool encounters an error that can be retried.
  • InvalidConfigError4: Raised when an issue occurs with storage.

PortiaBaseError Objects

class PortiaBaseError(Exception)

Base class for all our errors.

ConfigNotFoundError Objects

class ConfigNotFoundError(PortiaBaseError)

Raised when a required configuration value is not found.

Arguments:

  • value str - The name of the configuration value that is missing.

__init__

def __init__(value: str) -> None

Set custom error message.

InvalidConfigError Objects

class InvalidConfigError(PortiaBaseError)

Raised when a configuration value is invalid.

Arguments:

  • value str - The name of the invalid configuration value.
  • issue str - A description of the issue with the configuration value.

__init__

def __init__(value: str, issue: str) -> None

Set custom error message.

PlanError Objects

class PlanError(PortiaBaseError)

Base class for exceptions in the query planning_agent module.

This exception indicates an error that occurred during the planning phase.

Arguments:

  • error_string str - A description of the error encountered during planning.

__init__

def __init__(error_string: str) -> None

Set custom error message.

PlanNotFoundError Objects

class PlanNotFoundError(PortiaBaseError)

Raised when a plan with a specific ID is not found.

Arguments:

  • plan_id PlanUUID - The ID of the plan that was not found.

__init__

def __init__(plan_id: PlanUUID) -> None

Set custom error message.

PlanRunNotFoundError Objects

class PlanRunNotFoundError(PortiaBaseError)

Raised when a PlanRun with a specific ID is not found.

Arguments:

  • plan_run_id UUID | str | None - The ID or name of the PlanRun that was not found.

__init__

def __init__(plan_run_id: PlanRunUUID | str | None) -> None

Set custom error message.

ToolNotFoundError Objects

class ToolNotFoundError(PortiaBaseError)

Raised when a tool with a specific ID is not found.

Arguments:

  • tool_id str - The ID of the tool that was not found.

__init__

def __init__(tool_id: str) -> None

Set custom error message.

DuplicateToolError Objects

class DuplicateToolError(PortiaBaseError)

Raised when a tool is registered with the same name.

Arguments:

  • tool_id str - The ID of the tool that already exists.

__init__

def __init__(tool_id: str) -> None

Set custom error message.

InvalidToolDescriptionError Objects

class InvalidToolDescriptionError(PortiaBaseError)

Raised when a tool description is invalid.

Arguments:

  • tool_id str - The ID of the tool with an invalid description.

__init__

def __init__(tool_id: str) -> None

Set custom error message.

ToolRetryError Objects

class ToolRetryError(PortiaBaseError)

Raised when a tool fails after retrying.

Arguments:

  • tool_id str - The ID of the tool that failed.
  • error_string str - A description of the error that occurred.

__init__

def __init__(tool_id: str, error_string: str) -> None

Set custom error message.

ToolFailedError Objects

class ToolFailedError(PortiaBaseError)

Raised when a tool fails with a hard error.

Arguments:

  • tool_id str - The ID of the tool that failed.
  • error_string str - A description of the error that occurred.

__init__

def __init__(tool_id: str, error_string: str) -> None

Set custom error message.

InvalidPlanRunStateError Objects

class InvalidPlanRunStateError(PortiaBaseError)

Raised when a plan run is in an invalid state.

InvalidAgentError Objects

class InvalidAgentError(PortiaBaseError)

Raised when an agent is in an invalid state.

__init__

def __init__(state: str) -> None

Set custom error message.

InvalidAgentOutputError Objects

class InvalidAgentOutputError(PortiaBaseError)

Raised when the agent produces invalid output.

Arguments:

  • content str - The invalid content returned by the agent.

__init__

def __init__(content: str) -> None

Set custom error message.

ToolHardError Objects

class ToolHardError(PortiaBaseError)

Raised when a tool encounters an error it cannot retry.

Arguments:

  • cause Exception | str - The underlying exception or error message.

__init__

def __init__(cause: Exception | str) -> None

Set custom error message.

ToolSoftError Objects

class ToolSoftError(PortiaBaseError)

Raised when a tool encounters an error that can be retried.

Arguments:

  • cause Exception | str - The underlying exception or error message.

__init__

def __init__(cause: Exception | str) -> None

Set custom error message.

StorageError Objects

class StorageError(PortiaBaseError)

Raised when there's an issue with storage.

Arguments:

  • cause Exception | str - The underlying exception or error message.

__init__

def __init__(cause: Exception | str) -> None

Set custom error message.