errors
Error classification shared by services.
Provides a provider-agnostic vocabulary for why an operation failed, so that callers can tell a transient failure (worth retrying) from a permanent one (retrying will never help).
- class pipecat.utils.errors.ErrorCategory(*values)[source]
Bases:
EnumWhy an operation failed, independent of the provider that failed it.
- Parameters:
UNKNOWN – The cause could not be determined.
AUTHENTICATION – Credentials are missing or invalid.
AUTHORIZATION – Credentials are valid but lack access to the resource.
INVALID_REQUEST – The request itself is malformed or names something that doesn’t exist, such as an unknown model or voice.
RATE_LIMIT – Too many requests were sent in too short a window.
QUOTA – The account’s credit or usage allowance is exhausted.
CONNECTIVITY – The service could not be reached.
SERVER – The provider reported an internal failure.
APPLICATION – The application failed, not the provider. Reported by a service on behalf of code it invoked — a tool handler, say — or for application-supplied content a provider rejected once the service has repaired its context (e.g. removed the rejected file message). Either way the failure says nothing about the service’s own health.
CONTENT_FILTERED – The provider’s content policy rejected the request’s content. The failure is about that content, not the service’s health, but no response is coming for the request.
- UNKNOWN = 'unknown'
- AUTHENTICATION = 'authentication'
- AUTHORIZATION = 'authorization'
- INVALID_REQUEST = 'invalid_request'
- RATE_LIMIT = 'rate_limit'
- QUOTA = 'quota'
- CONNECTIVITY = 'connectivity'
- SERVER = 'server'
- APPLICATION = 'application'
- CONTENT_FILTERED = 'content_filtered'
- pipecat.utils.errors.classify_http_exception(exception: BaseException) ErrorCategory[source]
Classify an exception by the HTTP status code it carries.
- Parameters:
exception – The exception to classify.
- Returns:
The matching category, or ErrorCategory.UNKNOWN when the exception is not recognized. Providers that raise SDK-specific exceptions carrying no status code need their own classification.
- pipecat.utils.errors.classify_http_status_code(status_code: int) ErrorCategory[source]
Classify an HTTP status code.
- Parameters:
status_code – The HTTP status code reported by the provider.
- Returns:
The matching category, or ErrorCategory.UNKNOWN if the code carries no provider-independent meaning.
- pipecat.utils.errors.extract_http_status_code(exception: BaseException) int | None[source]
Extract an HTTP status code from an exception, if it carries one.
Recognizes the attribute shapes used by the HTTP and websocket libraries services build on: a
responseholdingstatus_code(httpx,websockets.exceptions.InvalidStatus) orstatus(aiohttp), and those same attributes directly on the exception (provider SDKs).- Parameters:
exception – The exception to inspect.
- Returns:
The status code, or None if the exception doesn’t carry one.