mod api;
mod oauth;
mod pkce;
mod stream;
pub use api::{ApiError, ApiErrorKind};
pub use oauth::{OAuthError, OAuthErrorCode};
pub use pkce::PkceError;
pub use stream::StreamError;
pub type Result<T> = std::result::Result<T, LichessError>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum LichessError {
#[error(transparent)]
Api(#[from] ApiError),
#[error(transparent)]
OAuth(#[from] OAuthError),
#[error("HTTP transport error")]
Transport(#[from] reqwest::Error),
#[error("failed to decode {context}")]
Decode {
context: String,
#[source]
source: serde_json::Error,
},
#[error(transparent)]
Stream(#[from] StreamError),
#[error("invalid request: {0}")]
InvalidRequest(String),
#[error(transparent)]
Pkce(#[from] PkceError),
}
impl LichessError {
pub(crate) fn decode(context: impl Into<String>, source: serde_json::Error) -> Self {
Self::Decode {
context: context.into(),
source,
}
}
}