Skip to main content

ibkr_client_portal/model/
error.rs

1#[derive(Debug)]
2pub enum StreamingError {
3    RequestError(reqwest::Error),
4    RequestMiddlewareError(anyhow::Error),
5    WebSocketError(tokio_tungstenite::tungstenite::Error),
6    OtherError(String),
7}
8
9pub fn tokio_tungstenite_error_to_streaming_error(
10    error: tokio_tungstenite::tungstenite::Error,
11) -> StreamingError {
12    StreamingError::WebSocketError(error)
13}
14
15pub fn reqwest_error_to_streaming_error(error: reqwest_middleware::Error) -> StreamingError {
16    match error {
17        reqwest_middleware::Error::Middleware(e) => StreamingError::RequestMiddlewareError(e),
18        reqwest_middleware::Error::Reqwest(e) => StreamingError::RequestError(e),
19    }
20}