1use polyte_core::ApiError;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, GammaError>;
6
7#[derive(Error, Debug)]
9pub enum GammaError {
10 #[error(transparent)]
12 Api(#[from] ApiError),
13}
14
15impl GammaError {
16 pub(crate) async fn from_response(response: reqwest::Response) -> Self {
18 Self::Api(ApiError::from_response(response).await)
19 }
20}
21
22impl From<reqwest::Error> for GammaError {
23 fn from(err: reqwest::Error) -> Self {
24 Self::Api(ApiError::Network(err))
25 }
26}
27
28impl From<url::ParseError> for GammaError {
29 fn from(err: url::ParseError) -> Self {
30 Self::Api(ApiError::Url(err))
31 }
32}
33
34impl From<serde_json::Error> for GammaError {
35 fn from(err: serde_json::Error) -> Self {
36 Self::Api(ApiError::Serialization(err))
37 }
38}