llm_wire/error
Describes why a call failed (Error) or could not be prepared
(PrepareError).
A failed call returns an llm_wire.Failure, whose error field is an
Error. Most callers decide with llm_wire.advise(failure) and log with
llm_wire.describe_failure(failure); branch on Error only for the
cases you handle differently:
case failure.error {
error.InvalidOutput(raw_output:, failure: reason) -> store(raw_output, reason)
error.Http(http_failure) -> log(http_error.describe(http_failure))
_ -> log(llm_wire.describe_failure(failure))
}
kind(error) is a closed classification that never gains variants, for
a caller that wants an exhaustive case; name(error) is a stable
identifier for logs and stored records.
Http carries HTTP Gun’s opaque Failure, so http_gun/error.kind,
is_retryable, status and headers apply to it directly.
prepare is pure, so its PrepareError never describes the network: it
names the setting, request field, schema or tool result that must
change. Error, PrepareError and their detail types may gain variants
in a minor release; match them with a _ arm. Strings in variants are
diagnostics for people; branch on the variants, never on the text.
Types
Why an executed call failed.
pub type Error {
Http(failure: error.Failure)
Status(
code: Int,
body: String,
retry_after: option.Option(duration.Duration),
)
Provider(code: option.Option(String), message: String)
Protocol(detail: String)
LimitExceeded(
limit: limit.Limit,
limit_value: Int,
measured: Int,
)
DeadlineExceeded(timeout: Timeout)
Cancelled
InvalidOutput(raw_output: String, failure: ValueFailure)
Stopped
ContentFiltered(stage: FilterStage, reason: String)
}
Constructors
-
Http(failure: error.Failure)The HTTP exchange failed. The opaque
Failurekeeps HTTP Gun’sKind, evidence, status and response headers. -
Status( code: Int, body: String, retry_after: option.Option(duration.Duration), )The provider answered with a status other than 200.
bodyis at mostlimit.ErrorBodyBytes;retry_aftercomes from aRetry-Afterheader in seconds or as an HTTP date. -
Provider(code: option.Option(String), message: String)The provider reported an error inside the stream.
-
Protocol(detail: String)The stream broke the provider’s protocol.
detailis diagnostic. -
LimitExceeded( limit: limit.Limit, limit_value: Int, measured: Int, )A bound was exceeded.
limitnames thellm_wire.with_limitsetting that raises it. -
DeadlineExceeded(timeout: Timeout)A timer expired;
timeoutnames thellm_wire.with_*_timeoutsetter. -
CancelledThe caller closed the stream or cancelled the call.
-
InvalidOutput(raw_output: String, failure: ValueFailure)The model’s final text is not valid structured output.
-
StoppedThe process that owned the call stopped before a result, for example because it could not start.
-
ContentFiltered(stage: FilterStage, reason: String)The provider’s safety system blocked the prompt or stopped the output.
reasonis the provider’s own value: OpenAI’sincomplete_details.reason("content_filter"), Anthropic’sstop_reason("refusal"), Gemini’sfinishReason("SAFETY","RECITATION","BLOCKLIST","PROHIBITED_CONTENT","SPII","IMAGE_SAFETY","IMAGE_PROHIBITED_CONTENT") orpromptFeedback.blockReason. Retrying the same request will not help. A model that declines in its own words is the outcomellm_wire.Refused, not this error.
Where a provider’s content filter stopped a call.
pub type FilterStage {
InPrompt
InOutput
}
Constructors
-
InPromptThe prompt was blocked before generation (Gemini’s
promptFeedback.blockReason). -
InOutputGeneration stopped after it started.
A small, closed classification of Error. Unlike Error, it gains no
variants in a minor release, so a case on it needs no _ arm. Branch
on it, decide retries with llm_wire.advise, and read Error for
detail.
pub type Kind {
Transport
ProviderError
ContentPolicy
UnusableResponse
OverLimit
Ended
}
Constructors
-
TransportHttporDeadlineExceeded: the exchange did not complete. -
ProviderErrorStatusorProvider: the provider answered with an error. -
ContentPolicyContentFiltered: the provider’s safety system stopped the call; the prompt must change. -
UnusableResponseProtocolorInvalidOutput: the response arrived but cannot be used. -
OverLimitLimitExceeded: a bound set withllm_wire.with_limitstopped the call. -
EndedCancelledorStopped: the call ended locally before a result.
Why llm_wire.prepare refused a configuration or request.
pub type PrepareError {
InvalidSetting(setting: Setting, reason: String)
InvalidRequest(problem: RequestProblem)
UnsupportedSchema(location: SchemaLocation, reason: String)
ToolResultMismatch(call_id: String, problem: ResultProblem)
RequestTooLarge(
limit: limit.Limit,
limit_value: Int,
measured: Int,
)
}
Constructors
-
InvalidSetting(setting: Setting, reason: String)A configuration value is invalid.
reasonis diagnostic. -
InvalidRequest(problem: RequestProblem)A request field or message is invalid for this provider.
-
UnsupportedSchema(location: SchemaLocation, reason: String)A tool or output schema cannot be sent to this provider.
-
ToolResultMismatch(call_id: String, problem: ResultProblem)Tool results do not match the calls of the assistant turn before them.
-
RequestTooLarge( limit: limit.Limit, limit_value: Int, measured: Int, )The request exceeds a bound before it is sent.
What is wrong with a request.
pub type RequestProblem {
InvalidClassificationContent(reason: String)
ClassificationQuestionUnsupported(question_id: String)
MaxTokensNotPositive
TemperatureOutOfRange
TopPOutOfRange
EmptyPromptCache
PromptCacheUnsupported
StopSequencesUnsupported
TooManyStopSequences(maximum: Int)
ImageUrlUnsupported
DuplicateToolName(name: String)
InvalidCallId(call_id: String)
InvalidToolName(name: String)
TurnFromOtherProvider
InvalidProviderData(reason: String)
}
Constructors
-
InvalidClassificationContent(reason: String)Classification state must be text, an object or an array within JSON limits.
-
ClassificationQuestionUnsupported(question_id: String)The classification wire cannot provide the requested question evidence.
-
MaxTokensNotPositive -
TemperatureOutOfRange -
TopPOutOfRange -
EmptyPromptCacheA prompt cache key or cached-content name is empty.
-
PromptCacheUnsupportedThe prompt cache reference belongs to another provider.
-
StopSequencesUnsupported -
TooManyStopSequences(maximum: Int) -
ImageUrlUnsupportedThis provider refuses remote image URLs; send inline image data.
-
DuplicateToolName(name: String) -
InvalidCallId(call_id: String)A call in the conversation has an empty id or a duplicate id.
-
InvalidToolName(name: String)A call in the conversation names a tool outside the tool-name grammar.
-
TurnFromOtherProviderAn assistant turn came from a different provider than this request.
-
InvalidProviderData(reason: String)An assistant turn’s provider data is missing, malformed or disagrees with its text and calls.
reasonis diagnostic.
How tool results disagree with the calls they answer.
pub type ResultProblem {
MissingResult
DuplicateResult
UnknownCall
NoPrecedingCalls
}
Constructors
-
MissingResult -
DuplicateResult -
UnknownCallThe result answers no call of the preceding assistant turn.
-
NoPrecedingCallsThe result follows no assistant turn with calls.
Where an unsupported schema was found.
pub type SchemaLocation {
ToolInput(tool: String)
Output
}
Constructors
-
ToolInput(tool: String) -
Output
A configuration value InvalidSetting names.
pub type Setting {
ApiKey
Model
Endpoint
Header
OutputName
LimitSetting(limit: limit.Limit)
TimeoutSetting(timeout: Timeout)
}
Constructors
-
ApiKey -
Model -
Endpoint -
Header -
OutputName -
LimitSetting(limit: limit.Limit) -
TimeoutSetting(timeout: Timeout)
The three timers of a call.
pub type Timeout {
WholeCall
FirstToken
IdleGap
}
Constructors
-
WholeCallFrom the start of execution to the final event. Default 600 s.
-
FirstTokenFrom the start of execution to the first progress event, covering admission, the response head and hidden reasoning. Default 180 s.
-
IdleGapThe longest gap between provider events after the first progress event. Every event resets it, including tool-argument deltas and pings. Default 60 s.
Why a JSON value (structured output or tool arguments) was refused.
pub type ValueFailure {
InvalidJson(value.ParseError)
SchemaRejected(contract.ValidationError)
DecodeRejected(codec.DecodeError)
}
Constructors
-
InvalidJson(value.ParseError)The text is not JSON within the parser’s bounds.
-
SchemaRejected(contract.ValidationError)The JSON does not satisfy the schema.
-
DecodeRejected(codec.DecodeError)The JSON satisfies the schema but the codec refused it.
Values
pub fn describe_prepare_error(error: PrepareError) -> String
A one-line description of a preparation error.
pub fn describe_value_failure(failure: ValueFailure) -> String
A one-line description of a refused JSON value.
pub fn kind_name(kind: Kind) -> String
A stable snake_case name, such as "content_policy".
pub fn name(error: Error) -> String
A stable identifier for logs and stored records, such as
"limit_exceeded.total_text_bytes" or "deadline_exceeded.first_token".
pub fn timeout_name(timeout: Timeout) -> String
A stable snake_case name: "whole_call", "first_token" or
"idle_gap".