pub enum AlpacaError {
Http(String),
Json(String),
Api {
status: u16,
message: String,
error_code: Option<ApiErrorCode>,
request_id: Option<String>,
},
Auth(String),
Config(String),
WebSocket(String),
RateLimit {
retry_after_secs: u64,
info: RateLimitInfo,
},
Network(String),
Timeout(String),
InvalidData(String),
Validation(String),
ValidationErrors(Vec<ValidationError>),
}Expand description
Error types for the Alpaca API client.
Variants§
Http(String)
HTTP request errors.
Json(String)
JSON parsing errors.
Api
API errors returned by Alpaca with full details.
Fields
error_code: Option<ApiErrorCode>Alpaca-specific error code.
Auth(String)
Authentication errors.
Config(String)
Invalid configuration.
WebSocket(String)
WebSocket errors.
RateLimit
Rate limiting errors with retry information.
Fields
info: RateLimitInfoFull rate limit information.
Network(String)
Network connectivity errors.
Timeout(String)
Timeout errors.
InvalidData(String)
Invalid data format.
Validation(String)
Validation errors with field-level details.
ValidationErrors(Vec<ValidationError>)
Multiple validation errors.
Implementations§
Source§impl AlpacaError
impl AlpacaError
Sourcepub fn api(status: u16, message: impl Into<String>) -> AlpacaError
pub fn api(status: u16, message: impl Into<String>) -> AlpacaError
Creates an API error from HTTP status and message.
Sourcepub fn api_with_details(
status: u16,
message: impl Into<String>,
error_code: ApiErrorCode,
request_id: Option<String>,
) -> AlpacaError
pub fn api_with_details( status: u16, message: impl Into<String>, error_code: ApiErrorCode, request_id: Option<String>, ) -> AlpacaError
Creates an API error with full details.
Sourcepub fn rate_limit(retry_after_secs: u64) -> AlpacaError
pub fn rate_limit(retry_after_secs: u64) -> AlpacaError
Creates a rate limit error.
Sourcepub fn rate_limit_with_info(info: RateLimitInfo) -> AlpacaError
pub fn rate_limit_with_info(info: RateLimitInfo) -> AlpacaError
Creates a rate limit error with full info.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if this error is retryable.
Sourcepub fn retry_after(&self) -> Option<u64>
pub fn retry_after(&self) -> Option<u64>
Returns the retry-after duration in seconds, if applicable.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the request ID if available.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Returns the HTTP status code if this is an API error.
Trait Implementations§
Source§impl Debug for AlpacaError
impl Debug for AlpacaError
Source§impl Display for AlpacaError
impl Display for AlpacaError
Source§impl Error for AlpacaError
impl Error for AlpacaError
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
Source§impl From<AlpacaError> for HttpError
impl From<AlpacaError> for HttpError
Source§fn from(source: AlpacaError) -> Self
fn from(source: AlpacaError) -> Self
Source§impl From<Error> for AlpacaError
impl From<Error> for AlpacaError
Source§fn from(err: Error) -> AlpacaError
fn from(err: Error) -> AlpacaError
Source§impl From<Error> for AlpacaError
impl From<Error> for AlpacaError
Source§fn from(err: Error) -> AlpacaError
fn from(err: Error) -> AlpacaError
Auto Trait Implementations§
impl Freeze for AlpacaError
impl RefUnwindSafe for AlpacaError
impl Send for AlpacaError
impl Sync for AlpacaError
impl Unpin for AlpacaError
impl UnwindSafe for AlpacaError
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.