use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("`{0}`")]
Io(#[from] std::io::Error),
#[error("Unable to compare version: {0}")]
Semver(#[from] semver::Error),
#[error("JSON error: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("Verify signature error: {0}")]
Minisign(#[from] minisign_verify::Error),
#[error("Signature decoding error: {0}")]
Base64(#[from] base64::DecodeError),
#[error(
"The signature {0} could not be decoded; check if it's a valid Base64 string. The signature must be the contents of the `.sig` file generated by the Millennium bundler, as a string."
)]
SignatureUtf8(String),
#[error("Millennium API error: {0}")]
MillenniumApi(#[from] crate::api::Error),
#[error("Network error: {0}")]
Network(String),
#[error("Could not fetch a valid release JSON from the remote update server.")]
ReleaseNotFound,
#[error("Unable to prepare the updater: {0}")]
Builder(String),
#[error("Unable to extract the new version: {0}")]
Extract(String),
#[error("Cannot run updater on this Linux package. Currently only an AppImage can be updated.")]
UnsupportedLinuxPackage,
#[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")]
UnsupportedOs,
#[error("Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`.")]
UnsupportedArch,
#[error("The platform `{0}` was not found in the update response `platforms` object.")]
TargetNotFound(String),
#[error("No updates available")]
UpToDate,
#[error("The updater response field `{0}` has an invalid type; expected {1}, but found {2}.")]
InvalidResponseType(&'static str, &'static str, serde_json::Value),
#[error(transparent)]
Http(#[from] http::Error)
}
pub type Result<T = ()> = std::result::Result<T, Error>;