Make errors non-exhaustive (#299)

This commit is contained in:
Cole Helbling 2023-03-03 12:03:51 -08:00 committed by GitHub
parent d7c14d6695
commit 49154b9863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 18 additions and 1 deletions

View file

@ -105,6 +105,7 @@ impl Action for FetchAndUnpackNix {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum FetchUrlError { pub enum FetchUrlError {
#[error("Request error")] #[error("Request error")]

View file

@ -96,6 +96,7 @@ impl Action for MoveUnpackedNix {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum MoveUnpackedNixError { pub enum MoveUnpackedNixError {
#[error("Glob pattern error")] #[error("Glob pattern error")]

View file

@ -246,6 +246,7 @@ impl Action for SetupDefaultProfile {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum SetupDefaultProfileError { pub enum SetupDefaultProfileError {
#[error("Glob pattern error")] #[error("Glob pattern error")]

View file

@ -333,6 +333,7 @@ impl Action for ConfigureInitService {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum ConfigureNixDaemonServiceError { pub enum ConfigureNixDaemonServiceError {
#[error("No supported init system found")] #[error("No supported init system found")]

View file

@ -107,6 +107,7 @@ impl Action for PlaceChannelConfiguration {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum PlaceChannelConfigurationError { pub enum PlaceChannelConfigurationError {
#[error("No root home found to place channel configuration in")] #[error("No root home found to place channel configuration in")]

View file

@ -138,6 +138,7 @@ impl Action for StartSystemdUnit {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum StartSystemdUnitError { pub enum StartSystemdUnitError {
#[error("Failed to execute command")] #[error("Failed to execute command")]

View file

@ -95,6 +95,7 @@ impl Action for BootstrapApfsVolume {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum BootstrapVolumeError { pub enum BootstrapVolumeError {
#[error("Failed to execute command")] #[error("Failed to execute command")]

View file

@ -136,6 +136,7 @@ impl Action for CreateApfsVolume {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum CreateApfsVolumeError { pub enum CreateApfsVolumeError {
#[error("Existing volume called `{0}` found in `diskutil apfs list`, delete it with `diskutil apfs deleteVolume \"{0}\"`")] #[error("Existing volume called `{0}` found in `diskutil apfs list`, delete it with `diskutil apfs deleteVolume \"{0}\"`")]

View file

@ -200,6 +200,7 @@ fn fstab_entry(uuid: &Uuid, apfs_volume_label: &str) -> String {
) )
} }
#[non_exhaustive]
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum CreateFstabEntryError { pub enum CreateFstabEntryError {
#[error("An `/etc/fstab` entry for the `/nix` path already exists, consider removing the entry for `/nix`d from `/etc/fstab`")] #[error("An `/etc/fstab` entry for the `/nix` path already exists, consider removing the entry for `/nix`d from `/etc/fstab`")]

View file

@ -88,6 +88,7 @@ impl Action for CreateSyntheticObjects {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum CreateSyntheticObjectsError { pub enum CreateSyntheticObjectsError {
#[error("Failed to execute command")] #[error("Failed to execute command")]

View file

@ -93,6 +93,7 @@ impl Action for EnableOwnership {
} }
} }
#[non_exhaustive]
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum EnableOwnershipError { pub enum EnableOwnershipError {
#[error("Failed to execute command")] #[error("Failed to execute command")]

View file

@ -253,6 +253,7 @@ impl ActionDescription {
} }
/// An error occurring during an action /// An error occurring during an action
#[non_exhaustive]
#[derive(thiserror::Error, Debug, strum::IntoStaticStr)] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)]
pub enum ActionError { pub enum ActionError {
/// A custom error /// A custom error

View file

@ -152,6 +152,7 @@ impl DiagnosticData {
} }
} }
#[non_exhaustive]
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum DiagnosticError { pub enum DiagnosticError {
#[error("Unknown url scheme")] #[error("Unknown url scheme")]

View file

@ -3,6 +3,7 @@ use std::path::PathBuf;
use crate::{action::ActionError, planner::PlannerError, settings::InstallSettingsError}; use crate::{action::ActionError, planner::PlannerError, settings::InstallSettingsError};
/// An error occurring during a call defined in this crate /// An error occurring during a call defined in this crate
#[non_exhaustive]
#[derive(thiserror::Error, Debug, strum::IntoStaticStr)] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)]
pub enum NixInstallerError { pub enum NixInstallerError {
/// An error originating from an [`Action`](crate::action::Action) /// An error originating from an [`Action`](crate::action::Action)

View file

@ -270,6 +270,7 @@ impl BuiltinPlanner {
} }
/// An error originating from a [`Planner`] /// An error originating from a [`Planner`]
#[non_exhaustive]
#[derive(thiserror::Error, Debug, strum::IntoStaticStr)] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)]
pub enum PlannerError { pub enum PlannerError {
/// `nix-installer` does not have a default planner for the target architecture right now /// `nix-installer` does not have a default planner for the target architecture right now

View file

@ -269,8 +269,9 @@ impl Into<BuiltinPlanner> for SteamDeck {
} }
} }
#[non_exhaustive]
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
enum SteamDeckError { pub enum SteamDeckError {
#[error("`{0}` is not a path that can be canonicalized into an absolute path, bind mounts require an absolute path")] #[error("`{0}` is not a path that can be canonicalized into an absolute path, bind mounts require an absolute path")]
AbsolutePathRequired(PathBuf), AbsolutePathRequired(PathBuf),
} }

View file

@ -561,6 +561,7 @@ impl InitSettings {
} }
/// An error originating from a [`Planner::settings`](crate::planner::Planner::settings) /// An error originating from a [`Planner::settings`](crate::planner::Planner::settings)
#[non_exhaustive]
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum InstallSettingsError { pub enum InstallSettingsError {
/// `nix-installer` does not support the architecture right now /// `nix-installer` does not support the architecture right now