fastrag.exceptions#
Exception hierarchy.
Every error raised by the SDK derives from FastragError, so a caller
can catch the whole package with one except. TransientError is a
mixin rather than a branch of the tree, so an exception can be both typed by
origin — a fetch failure, an embedding failure — and marked retryable.
describe_error() is the counterpart for reporting one: not every
exception that reaches a failure handler is one of ours, and a third-party
exception raised with no arguments formats as an empty string.
Functions
|
Format |
Exceptions
The step cache could not be read or written. |
|
A chat completion request failed. |
|
A chat store operation (session, chat, or message) could not be completed. |
|
A document could not be chunked. |
|
Invalid arguments, a missing optional dependency, or a bad template. |
|
The prompt exceeded the model's context window. |
|
An embedding request failed. |
|
Base class for every error raised by Fastrag. |
|
A resource could not be fetched. |
|
A resource could not be parsed. |
|
A rerank request failed. |
|
A client for something outside the process failed. |
|
A source could not be turned into documents. |
|
A cache operation failed on lock contention or a lost connection. |
|
A chat completion failed for a reason that may succeed on retry. |
|
A chat store operation failed on lock contention or a lost connection. |
|
An embedding failed for a reason that may succeed on retry. |
|
Mixin marking an error worth retrying. |
|
A fetch failed for a reason that may succeed on retry (network, 5xx). |
|
Parsing failed because of a temporary model or network failure. |
|
A rerank failed for a reason that may succeed on retry. |
|
A vector store operation failed for a reason that may succeed on retry. |
|
A vector store operation failed. |
- exception fastrag.exceptions.FastragError[source]#
Bases:
ExceptionBase class for every error raised by Fastrag.
- exception fastrag.exceptions.TransientError[source]#
Bases:
FastragErrorMixin marking an error worth retrying.
Only exceptions carrying this mixin are retried by
Policy: a timeout is transient, a malformed document is not.
- exception fastrag.exceptions.ConfigurationError[source]#
Bases:
FastragErrorInvalid arguments, a missing optional dependency, or a bad template.
Always raised as early as possible — at construction, not at first use.
- exception fastrag.exceptions.SourceError[source]#
Bases:
FastragErrorA source could not be turned into documents.
- exception fastrag.exceptions.FetchError[source]#
Bases:
SourceErrorA resource could not be fetched.
- exception fastrag.exceptions.TransientFetchError[source]#
Bases:
FetchError,TransientErrorA fetch failed for a reason that may succeed on retry (network, 5xx).
- exception fastrag.exceptions.ParseError[source]#
Bases:
SourceErrorA resource could not be parsed.
- exception fastrag.exceptions.TransientParseError[source]#
Bases:
ParseError,TransientErrorParsing failed because of a temporary model or network failure.
- exception fastrag.exceptions.ChunkingError[source]#
Bases:
FastragErrorA document could not be chunked.
- exception fastrag.exceptions.ServiceError[source]#
Bases:
FastragErrorA client for something outside the process failed.
- exception fastrag.exceptions.EmbeddingError[source]#
Bases:
ServiceErrorAn embedding request failed.
- exception fastrag.exceptions.TransientEmbeddingError[source]#
Bases:
EmbeddingError,TransientErrorAn embedding failed for a reason that may succeed on retry.
- exception fastrag.exceptions.ChatError[source]#
Bases:
ServiceErrorA chat completion request failed.
- exception fastrag.exceptions.TransientChatError[source]#
Bases:
ChatError,TransientErrorA chat completion failed for a reason that may succeed on retry.
- exception fastrag.exceptions.ContextLengthError[source]#
Bases:
ChatErrorThe prompt exceeded the model’s context window.
Deliberately not a
TransientError: retrying an over-long prompt produces the same failure, soPolicymust not retry it.
- exception fastrag.exceptions.RerankError[source]#
Bases:
ServiceErrorA rerank request failed.
- exception fastrag.exceptions.TransientRerankError[source]#
Bases:
RerankError,TransientErrorA rerank failed for a reason that may succeed on retry.
- exception fastrag.exceptions.VectorStoreError[source]#
Bases:
ServiceErrorA vector store operation failed.
- exception fastrag.exceptions.TransientVectorStoreError[source]#
Bases:
VectorStoreError,TransientErrorA vector store operation failed for a reason that may succeed on retry.
- exception fastrag.exceptions.CacheError[source]#
Bases:
FastragErrorThe step cache could not be read or written.
- exception fastrag.exceptions.TransientCacheError[source]#
Bases:
CacheError,TransientErrorA cache operation failed on lock contention or a lost connection.
- exception fastrag.exceptions.ChatStoreError[source]#
Bases:
FastragErrorA chat store operation (session, chat, or message) could not be completed.
- exception fastrag.exceptions.TransientChatStoreError[source]#
Bases:
ChatStoreError,TransientErrorA chat store operation failed on lock contention or a lost connection.
- fastrag.exceptions.describe_error(error)[source]#
Format
errorfor a human, never as an empty string.f"{error}"is the obvious way to render theerroron anItemFailedorStepFailed, and it renders an exception raised with no arguments —TimeoutError(),asyncio.CancelledError(), a bare third-party sentinel — as nothing at all, turning a real failure into a blank line. This falls back to the exception’s type name in that case, and prefixes it otherwise, so a failure always says at minimum what kind of failure it was.describe_error(TimeoutError()) # -> "TimeoutError" describe_error(ParseError("bad xlsx")) # -> "ParseError: bad xlsx"
- Parameters:
error (BaseException) – The exception to describe.
- Returns:
"<type>: <message>", or just"<type>"when the exception carries no message.- Return type: