#[non_exhaustive]pub enum Error {
Transport(TransportError),
Encode(Box<dyn Error + Send + Sync>),
Decode(Box<dyn Error + Send + Sync>),
Api {
code: String,
message: String,
},
HttpStatus {
status: StatusCode,
body: String,
},
Configuration(String),
}Expand description
Errors that can occur while making an OKX API request.
The enum is #[non_exhaustive]
so new variants can be added without a breaking change. Downstream code can
match on Error::Api and inspect the OKX error code (kept as a String,
since OKX codes are not guaranteed to be parseable integers).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Transport(TransportError)
The underlying HTTP transport failed (connection, TLS, timeout, …).
Encode(Box<dyn Error + Send + Sync>)
The request could not be encoded (query string or JSON body).
Decode(Box<dyn Error + Send + Sync>)
The response body could not be decoded into the expected model.
Api
OKX returned a non-zero response code.
Fields
HttpStatus
The HTTP response had a non-success status before the OKX response envelope could be decoded.
Fields
status: StatusCodeHTTP response status code.
Configuration(String)
The client was used in an invalid way (e.g. an authenticated endpoint was called without credentials).
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()