use rootcause::{Report, ReportConversion, markers};
use std::borrow::Cow;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("URL parse error: {0}")]
UrlParsing(#[from] url::ParseError),
#[error("HTTP request failed: {0}")]
Request(#[from] reqwest::Error),
#[error("Platform (os: {os}, arch: {arch}) is not supported.")]
UnsupportedPlatform {
os: Cow<'static, str>,
arch: Cow<'static, str>,
},
}
impl<T> ReportConversion<url::ParseError, markers::Mutable, T> for Error
where
Error: markers::ObjectMarkerFor<T>,
{
fn convert_report(
report: Report<url::ParseError, markers::Mutable, T>,
) -> Report<Self, markers::Mutable, T> {
report.context_transform(Error::UrlParsing)
}
}
impl<T> ReportConversion<reqwest::Error, markers::Mutable, T> for Error
where
Error: markers::ObjectMarkerFor<T>,
{
fn convert_report(
report: Report<reqwest::Error, markers::Mutable, T>,
) -> Report<Self, markers::Mutable, T> {
report.context_transform(Error::Request)
}
}