pub enum Error {
Http(Error),
Json(Error),
Config(String),
Api {
status: Option<u16>,
message: String,
},
Stream(String),
Tool(String),
InvalidInput(String),
Timeout,
Other(String),
}Expand description
Errors from configuration, transport, stream decoding, and tool execution.
reqwest::Error and serde_json::Error convert automatically through ?.
Variants§
Http(Error)
A reqwest transport error, including connection failures and timeouts.
Json(Error)
A serde JSON serialization or deserialization error.
Config(String)
Invalid SDK configuration.
Api
A model API error with an optional structured HTTP status.
Use Error::api_status when a status is available. Retry classification uses
that field, never status-like text in the message.
Fields
Stream(String)
An SSE or stream-processing error.
Tool(String)
A tool lookup or execution error.
InvalidInput(String)
Invalid input to an SDK operation.
Timeout
An explicit SDK timeout error.
Other(String)
An error without a more specific category.
Implementations§
Source§impl Error
impl Error
Sourcepub fn api(msg: impl Into<String>) -> Self
pub fn api(msg: impl Into<String>) -> Self
Creates an API error without a status.
It is non-retryable regardless of the message. Use api_status
when the HTTP status is known.
Sourcepub fn api_status(status: u16, msg: impl Into<String>) -> Self
pub fn api_status(status: u16, msg: impl Into<String>) -> Self
Create a new API error from an HTTP error response.
Prefer this over Error::api whenever a status code is available: retry
classification reads Error::status_code, and an error built without a status is
treated as non-retryable no matter what its message says.
§Arguments
status- HTTP status code from the responsemsg- Response body or error message from the API server
§Example
use open_agent::Error;
let err = Error::api_status(429, "Rate limit exceeded");
assert_eq!(err.to_string(), "API error 429: Rate limit exceeded");
assert_eq!(err.status_code(), Some(429));Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Returns the status carried by Error::Api, or None.
No other variant exposes a status through this method.
Sourcepub fn invalid_input(msg: impl Into<String>) -> Self
pub fn invalid_input(msg: impl Into<String>) -> Self
Creates an invalid-input error.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()