#[non_exhaustive]pub enum Error {
Transport(Error),
Api {
status: StatusCode,
request_id: Option<String>,
body: ApiErrorBody,
},
Decode {
source: Error,
body: String,
},
Stream(String),
Config(String),
}Expand description
The unified error type returned by every SDK operation.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Transport(Error)
The HTTP request could not be performed (connection, TLS, timeout, …).
Api
OANDA answered with a non-success HTTP status.
The parsed error body is available in Error::Api::body; the raw
payload of order-reject responses can be recovered with
ApiErrorBody::details.
Decode
A 2xx response body could not be deserialized into the expected type.
Fields
Stream(String)
A streaming connection violated the expected protocol.
Config(String)
The client was configured with invalid values.
Implementations§
Source§impl Error
impl Error
Sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
The HTTP status code associated with this error, if any.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The RequestID header OANDA attached to the failing response, if any.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Whether this error was caused by OANDA’s rate limiting (HTTP 429).
OANDA allows 120 REST requests per second and 2 new connections per
second per IP address. The client’s built-in rate limiter (see
ClientBuilder) keeps you below those limits
by default, so this should only occur when rate limiting was disabled
or other processes share the same IP.
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()