use {
reqwest::{Error as HttpError, Response},
serde::Deserialize,
std::result::Result as StdResult,
thiserror::Error,
tokio_tungstenite::tungstenite::Error as WsError,
};
pub type Result<T = (), E = Error> = StdResult<T, E>;
#[derive(Error, Debug)]
pub enum Error {
#[error("Http error: {0}")]
Http(#[from] HttpError),
#[error("Unsuccessful request: {0:?}")]
UnsuccessfulRequest(Response),
#[error("WebSocket error: {0}")]
Ws(#[from] WsError),
#[error("Authentication error: {0}")]
Authentication(#[from] AuthenticationError),
#[error("Unknown error: {0}")]
Unknown(String),
}
#[derive(Error, Debug, Deserialize, Clone, Copy, PartialEq)]
pub enum AuthenticationError {
#[error("LabelMe")]
LabelMe,
#[error("InternalError")]
InternalError,
#[error("InvalidSession")]
InvalidSession,
#[error("AlreadyAuthenticated")]
AlreadyAuthenticated,
}