pub enum SwarmError {
Show 23 variants
ApiError(String),
ConfigError(String),
AgentError(String),
ValidationError(String),
RateLimitError(String),
NetworkError(String),
TimeoutError(String),
AuthError(String),
ReqwestError(Error),
EnvVarError(VarError),
SerializationError(String),
DeserializationError(String),
XmlError(String),
AgentNotFoundError(String),
FunctionError(String),
StreamError(String),
ContextError(String),
MaxIterationsError {
max: usize,
actual: usize,
},
JsonError(Error),
XmlParseError(DeError),
Other(String),
RequestTimeoutError(u64),
UrlValidationError(String),
}Expand description
Main error type for the Swarm library
Encompasses all possible error conditions that can occur during Swarm operations, from API communication to agent execution.
§Examples
use rswarm::SwarmError;
let error = SwarmError::ApiError("Rate limit exceeded".to_string());
assert_eq!(error.to_string(), "API error: Rate limit exceeded");
// Checking if an error is retriable
assert!(SwarmError::NetworkError("Connection refused".to_string()).is_retriable());Variants§
ApiError(String)
Errors returned by the API
ConfigError(String)
Configuration-related errors
AgentError(String)
Errors related to agent execution
ValidationError(String)
Input validation errors
RateLimitError(String)
Rate limiting errors from the API
NetworkError(String)
Network communication errors
TimeoutError(String)
Timeout-related errors
AuthError(String)
Authentication and authorization errors
ReqwestError(Error)
HTTP client errors from reqwest
EnvVarError(VarError)
Environment variable errors
SerializationError(String)
Data serialization errors
DeserializationError(String)
Data deserialization errors
XmlError(String)
XML parsing and processing errors
AgentNotFoundError(String)
Errors when an agent is not found in the registry
FunctionError(String)
Function execution errors
StreamError(String)
Stream processing errors
ContextError(String)
Context variables related errors
MaxIterationsError
Maximum iterations exceeded errors
JsonError(Error)
JSON processing errors
XmlParseError(DeError)
XML parsing errors from quick-xml
Other(String)
Generic/catch-all errors
RequestTimeoutError(u64)
Request timeout errors with duration
UrlValidationError(String)
URL validation errors
Implementations§
Source§impl SwarmError
impl SwarmError
Sourcepub fn is_retriable(&self) -> bool
pub fn is_retriable(&self) -> bool
Determines if the error is potentially retriable
Returns true for errors that might succeed on retry, such as network errors, timeouts, and rate limit errors.
§Examples
use rswarm::SwarmError;
let error = SwarmError::NetworkError("Connection reset".to_string());
assert!(error.is_retriable());
let error = SwarmError::ValidationError("Invalid input".to_string());
assert!(!error.is_retriable());Sourcepub fn is_configuration_error(&self) -> bool
pub fn is_configuration_error(&self) -> bool
Determines if the error is related to configuration
Returns true for errors that indicate configuration problems, such as invalid settings or missing credentials.
§Examples
use rswarm::SwarmError;
let error = SwarmError::ConfigError("Invalid API URL".to_string());
assert!(error.is_configuration_error());
let error = SwarmError::NetworkError("Connection failed".to_string());
assert!(!error.is_configuration_error());Trait Implementations§
Source§impl Debug for SwarmError
impl Debug for SwarmError
Source§impl Display for SwarmError
impl Display for SwarmError
Source§impl Error for SwarmError
impl Error for SwarmError
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()
Source§impl From<BudgetExhausted> for SwarmError
impl From<BudgetExhausted> for SwarmError
Source§fn from(e: BudgetExhausted) -> Self
fn from(e: BudgetExhausted) -> Self
Source§impl From<DeError> for SwarmError
impl From<DeError> for SwarmError
Source§impl From<Error> for SwarmError
impl From<Error> for SwarmError
Source§impl From<Error> for SwarmError
impl From<Error> for SwarmError
Source§impl From<Error> for SwarmError
Implement From for common error conversions
impl From<Error> for SwarmError
Implement From for common error conversions
Source§impl From<Error> for SwarmError
impl From<Error> for SwarmError
Auto Trait Implementations§
impl Freeze for SwarmError
impl !RefUnwindSafe for SwarmError
impl Send for SwarmError
impl Sync for SwarmError
impl Unpin for SwarmError
impl UnsafeUnpin for SwarmError
impl !UnwindSafe for SwarmError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.