2018-12-11 16:43:26 +02:00
|
|
|
use std::process::ExitStatus;
|
2022-01-06 06:27:37 +02:00
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
use thiserror::Error;
|
2018-12-11 16:43:26 +02:00
|
|
|
|
2022-10-10 18:29:56 +00:00
|
|
|
#[derive(Error, Debug, PartialEq, Eq)]
|
2019-12-11 23:05:38 +02:00
|
|
|
pub enum TopgradeError {
|
2022-11-23 15:18:09 +00:00
|
|
|
#[error("`{0}` failed: {1}")]
|
|
|
|
|
ProcessFailed(String, ExitStatus),
|
2018-12-11 16:43:26 +02:00
|
|
|
|
2022-11-23 15:18:09 +00:00
|
|
|
#[error("`{0}` failed: {1}")]
|
|
|
|
|
ProcessFailedWithOutput(String, ExitStatus, String),
|
2020-06-25 08:37:29 +03:00
|
|
|
|
2019-12-12 20:24:22 +02:00
|
|
|
#[error("Sudo is required for this step")]
|
2020-04-03 12:19:55 +03:00
|
|
|
#[allow(dead_code)]
|
2019-12-12 20:24:22 +02:00
|
|
|
SudoRequired,
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
#[error("Unknown Linux Distribution")]
|
2018-12-11 16:43:26 +02:00
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
UnknownLinuxDistribution,
|
2022-01-06 06:27:37 +02:00
|
|
|
|
|
|
|
|
#[error("Failed getting the system package manager")]
|
|
|
|
|
#[cfg(target_os = "linux")]
|
|
|
|
|
FailedGettingPackageManager,
|
2018-12-11 16:43:26 +02:00
|
|
|
}
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
|
#[error("A step failed")]
|
|
|
|
|
pub struct StepFailed;
|
2018-12-11 16:43:26 +02:00
|
|
|
|
2021-02-27 06:41:55 +02:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
|
#[error("Dry running")]
|
|
|
|
|
pub struct DryRun();
|
|
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
#[derive(Error, Debug)]
|
2020-08-21 23:04:36 +03:00
|
|
|
#[error("{0}")]
|
|
|
|
|
pub struct SkipStep(pub String);
|
2018-12-11 16:43:26 +02:00
|
|
|
|
2019-12-11 23:05:38 +02:00
|
|
|
#[cfg(all(windows, feature = "self-update"))]
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
|
#[error("Topgrade Upgraded")]
|
|
|
|
|
pub struct Upgraded(pub ExitStatus);
|