use crate::transport::TransportError;
#[cfg(feature = "websocket")]
pub use crate::ws::WsError;
type BoxError = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
Rest(#[from] RestError),
#[cfg(feature = "websocket")]
#[error(transparent)]
Ws(#[from] WsError),
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum RestError {
#[error("transport error: {source}")]
Transport {
#[from]
source: TransportError,
},
#[error("HTTP {status} from {endpoint}")]
HttpStatus {
endpoint: &'static str,
status: http::StatusCode,
body: String,
},
#[error("OKX API error {code} from {endpoint}: {message}")]
Okx {
endpoint: &'static str,
code: String,
message: String,
},
#[error("failed to decode response from {endpoint}")]
Decode {
endpoint: &'static str,
#[source]
source: serde_json::Error,
},
#[error("failed to encode request")]
Encode {
#[source]
source: BoxError,
},
#[error("invalid configuration: {0}")]
Configuration(String),
}