Exceptions

Exceptions of the Proxy passthrough.

Each one is an HTTP error response to the caller: its ProxyError.status and ProxyError.code. They derive from Exception, not SmarterException, which logs every instance as an error: most of them are the caller’s mistakes, e.g. an unknown Proxy, and are logged as warnings.

exception smarter.apps.proxy.exceptions.ProxyBudgetExceeded(message)[source]

Bases: ProxyError

A budget’s resource lock forbids charges to the Proxy, its Provider, the caller, or the caller’s account.

code: str = 'budget_exceeded'
status: int = 402
exception smarter.apps.proxy.exceptions.ProxyConfigurationError(message)[source]

Bases: ProxyError

The Proxy cannot forward requests: it has no base URL or API key, or its host is not allowed.

code: str = 'proxy_misconfigured'
status: int = 503
exception smarter.apps.proxy.exceptions.ProxyError(message)[source]

Bases: Exception

Base class of the Proxy passthrough’s errors: a 502 Bad Gateway, unless a subclass says otherwise.

__init__(message)[source]
code: str = 'proxy_error'
status: int = 502
to_dict()[source]

The error, in the shape that the OpenAI and Anthropic SDKs report: {"error": {...}}.

Return type:

dict

exception smarter.apps.proxy.exceptions.ProxyInactive(message)[source]

Bases: ProxyError

The Proxy is inactive: spec.isActive is false.

code: str = 'proxy_inactive'
status: int = 403
exception smarter.apps.proxy.exceptions.ProxyNotFound(message)[source]

Bases: ProxyError

No Proxy of that name exists that the caller may use.

code: str = 'proxy_not_found'
status: int = 404
exception smarter.apps.proxy.exceptions.ProxyPathNotAllowed(message)[source]

Bases: ProxyError

The path is not one of the Proxy’s spec.allowedPaths, or would leave its base URL.

code: str = 'path_not_allowed'
status: int = 403
exception smarter.apps.proxy.exceptions.ProxyUpstreamError(message)[source]

Bases: ProxyError

The provider’s API could not be reached.

code: str = 'upstream_unreachable'
status: int = 502
exception smarter.apps.proxy.exceptions.ProxyUpstreamTimeout(message)[source]

Bases: ProxyError

The provider’s API did not respond within the Proxy’s spec.timeout.

code: str = 'upstream_timeout'
status: int = 504