use crate::config::AuthType;
#[derive(Clone, Debug)]
pub struct DynamicApiError(String);
pub fn wrong_auth_token_error_message<Q>(
current_authtype: AuthType,
expected_authtypes: &[AuthType],
) -> String {
format!(
"Query <{}> not supported on auth type {:?}. Expected auth type: {:?}",
std::any::type_name::<Q>(),
current_authtype,
expected_authtypes
)
}
impl std::error::Error for DynamicApiError {}
impl std::fmt::Display for DynamicApiError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Error recieved when creating API: <{}>", self.0)
}
}
impl From<ytmapi_rs::Error> for DynamicApiError {
fn from(value: ytmapi_rs::Error) -> Self {
DynamicApiError(value.to_string())
}
}