From 49154b98634da5095edc34d0b92f0870c2e73057 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 3 Mar 2023 12:03:51 -0800 Subject: [PATCH] Make errors non-exhaustive (#299) --- src/action/base/fetch_and_unpack_nix.rs | 1 + src/action/base/move_unpacked_nix.rs | 1 + src/action/base/setup_default_profile.rs | 1 + src/action/common/configure_init_service.rs | 1 + src/action/common/place_channel_configuration.rs | 1 + src/action/linux/start_systemd_unit.rs | 1 + src/action/macos/bootstrap_apfs_volume.rs | 1 + src/action/macos/create_apfs_volume.rs | 1 + src/action/macos/create_fstab_entry.rs | 1 + src/action/macos/create_synthetic_objects.rs | 1 + src/action/macos/enable_ownership.rs | 1 + src/action/mod.rs | 1 + src/diagnostics.rs | 1 + src/error.rs | 1 + src/planner/mod.rs | 1 + src/planner/steam_deck.rs | 3 ++- src/settings.rs | 1 + 17 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/action/base/fetch_and_unpack_nix.rs b/src/action/base/fetch_and_unpack_nix.rs index 0f98ba8..536d8e9 100644 --- a/src/action/base/fetch_and_unpack_nix.rs +++ b/src/action/base/fetch_and_unpack_nix.rs @@ -105,6 +105,7 @@ impl Action for FetchAndUnpackNix { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum FetchUrlError { #[error("Request error")] diff --git a/src/action/base/move_unpacked_nix.rs b/src/action/base/move_unpacked_nix.rs index f5aaae9..b8a21ab 100644 --- a/src/action/base/move_unpacked_nix.rs +++ b/src/action/base/move_unpacked_nix.rs @@ -96,6 +96,7 @@ impl Action for MoveUnpackedNix { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum MoveUnpackedNixError { #[error("Glob pattern error")] diff --git a/src/action/base/setup_default_profile.rs b/src/action/base/setup_default_profile.rs index cdb61b2..39ac403 100644 --- a/src/action/base/setup_default_profile.rs +++ b/src/action/base/setup_default_profile.rs @@ -246,6 +246,7 @@ impl Action for SetupDefaultProfile { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum SetupDefaultProfileError { #[error("Glob pattern error")] diff --git a/src/action/common/configure_init_service.rs b/src/action/common/configure_init_service.rs index 3e7e9bb..82eea1a 100644 --- a/src/action/common/configure_init_service.rs +++ b/src/action/common/configure_init_service.rs @@ -333,6 +333,7 @@ impl Action for ConfigureInitService { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum ConfigureNixDaemonServiceError { #[error("No supported init system found")] diff --git a/src/action/common/place_channel_configuration.rs b/src/action/common/place_channel_configuration.rs index 9084f4d..c87b1d4 100644 --- a/src/action/common/place_channel_configuration.rs +++ b/src/action/common/place_channel_configuration.rs @@ -107,6 +107,7 @@ impl Action for PlaceChannelConfiguration { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum PlaceChannelConfigurationError { #[error("No root home found to place channel configuration in")] diff --git a/src/action/linux/start_systemd_unit.rs b/src/action/linux/start_systemd_unit.rs index c59457a..485d0b0 100644 --- a/src/action/linux/start_systemd_unit.rs +++ b/src/action/linux/start_systemd_unit.rs @@ -138,6 +138,7 @@ impl Action for StartSystemdUnit { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum StartSystemdUnitError { #[error("Failed to execute command")] diff --git a/src/action/macos/bootstrap_apfs_volume.rs b/src/action/macos/bootstrap_apfs_volume.rs index 958b457..c448a82 100644 --- a/src/action/macos/bootstrap_apfs_volume.rs +++ b/src/action/macos/bootstrap_apfs_volume.rs @@ -95,6 +95,7 @@ impl Action for BootstrapApfsVolume { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum BootstrapVolumeError { #[error("Failed to execute command")] diff --git a/src/action/macos/create_apfs_volume.rs b/src/action/macos/create_apfs_volume.rs index 738d193..00e05a4 100644 --- a/src/action/macos/create_apfs_volume.rs +++ b/src/action/macos/create_apfs_volume.rs @@ -136,6 +136,7 @@ impl Action for CreateApfsVolume { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum CreateApfsVolumeError { #[error("Existing volume called `{0}` found in `diskutil apfs list`, delete it with `diskutil apfs deleteVolume \"{0}\"`")] diff --git a/src/action/macos/create_fstab_entry.rs b/src/action/macos/create_fstab_entry.rs index 106e87a..cfac0cb 100644 --- a/src/action/macos/create_fstab_entry.rs +++ b/src/action/macos/create_fstab_entry.rs @@ -200,6 +200,7 @@ fn fstab_entry(uuid: &Uuid, apfs_volume_label: &str) -> String { ) } +#[non_exhaustive] #[derive(thiserror::Error, Debug)] pub enum CreateFstabEntryError { #[error("An `/etc/fstab` entry for the `/nix` path already exists, consider removing the entry for `/nix`d from `/etc/fstab`")] diff --git a/src/action/macos/create_synthetic_objects.rs b/src/action/macos/create_synthetic_objects.rs index 061883f..f671881 100644 --- a/src/action/macos/create_synthetic_objects.rs +++ b/src/action/macos/create_synthetic_objects.rs @@ -88,6 +88,7 @@ impl Action for CreateSyntheticObjects { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum CreateSyntheticObjectsError { #[error("Failed to execute command")] diff --git a/src/action/macos/enable_ownership.rs b/src/action/macos/enable_ownership.rs index 9c0f700..a59e86e 100644 --- a/src/action/macos/enable_ownership.rs +++ b/src/action/macos/enable_ownership.rs @@ -93,6 +93,7 @@ impl Action for EnableOwnership { } } +#[non_exhaustive] #[derive(Debug, thiserror::Error)] pub enum EnableOwnershipError { #[error("Failed to execute command")] diff --git a/src/action/mod.rs b/src/action/mod.rs index 384ecf3..0505ecf 100644 --- a/src/action/mod.rs +++ b/src/action/mod.rs @@ -253,6 +253,7 @@ impl ActionDescription { } /// An error occurring during an action +#[non_exhaustive] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)] pub enum ActionError { /// A custom error diff --git a/src/diagnostics.rs b/src/diagnostics.rs index a17e401..9b52e90 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -152,6 +152,7 @@ impl DiagnosticData { } } +#[non_exhaustive] #[derive(thiserror::Error, Debug)] pub enum DiagnosticError { #[error("Unknown url scheme")] diff --git a/src/error.rs b/src/error.rs index 9f3a73a..aabda62 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use crate::{action::ActionError, planner::PlannerError, settings::InstallSettingsError}; /// An error occurring during a call defined in this crate +#[non_exhaustive] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)] pub enum NixInstallerError { /// An error originating from an [`Action`](crate::action::Action) diff --git a/src/planner/mod.rs b/src/planner/mod.rs index c46d797..75a05f8 100644 --- a/src/planner/mod.rs +++ b/src/planner/mod.rs @@ -270,6 +270,7 @@ impl BuiltinPlanner { } /// An error originating from a [`Planner`] +#[non_exhaustive] #[derive(thiserror::Error, Debug, strum::IntoStaticStr)] pub enum PlannerError { /// `nix-installer` does not have a default planner for the target architecture right now diff --git a/src/planner/steam_deck.rs b/src/planner/steam_deck.rs index 3936452..8b52b07 100644 --- a/src/planner/steam_deck.rs +++ b/src/planner/steam_deck.rs @@ -269,8 +269,9 @@ impl Into for SteamDeck { } } +#[non_exhaustive] #[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")] AbsolutePathRequired(PathBuf), } diff --git a/src/settings.rs b/src/settings.rs index 69aebf6..c33f44e 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -561,6 +561,7 @@ impl InitSettings { } /// An error originating from a [`Planner::settings`](crate::planner::Planner::settings) +#[non_exhaustive] #[derive(thiserror::Error, Debug)] pub enum InstallSettingsError { /// `nix-installer` does not support the architecture right now