tauri_plugin_http/
error.rsuse serde::{Serialize, Serializer};
use url::Url;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Network(#[from] reqwest::Error),
#[error(transparent)]
Http(#[from] http::Error),
#[error(transparent)]
HttpInvalidHeaderName(#[from] http::header::InvalidHeaderName),
#[error(transparent)]
HttpInvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
#[error("url not allowed on the configured scope: {0}")]
UrlNotAllowed(Url),
#[error(transparent)]
UrlParseError(#[from] url::ParseError),
#[error(transparent)]
HttpMethod(#[from] http::method::InvalidMethod),
#[error("scheme {0} not supported")]
SchemeNotSupport(String),
#[error("Request canceled")]
RequestCanceled,
#[error(transparent)]
FsError(#[from] tauri_plugin_fs::Error),
#[error("failed to process data url")]
DataUrlError,
#[error("failed to decode data url into bytes")]
DataUrlDecodeError,
#[error(transparent)]
Tauri(#[from] tauri::Error),
#[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error),
}
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}
pub type Result<T> = std::result::Result<T, Error>;