diff --git a/Cargo.lock b/Cargo.lock index 25fb63604e..50628dd1af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10302,7 +10302,6 @@ dependencies = [ "sled-hardware", "slog", "slog-dtrace", - "snafu", "subprocess", "tar", "thiserror", diff --git a/Cargo.toml b/Cargo.toml index f7c5b11aba..3d22af19a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -355,7 +355,6 @@ slog-envlogger = "2.2" slog-error-chain = { git = "https://github.com/oxidecomputer/slog-error-chain", branch = "main", features = ["derive"] } slog-term = "2.9" smf = "0.2" -snafu = "0.7" sp-sim = { path = "sp-sim" } sprockets-common = { git = "http://github.com/oxidecomputer/sprockets", rev = "77df31efa5619d0767ffc837ef7468101608aee9" } sprockets-host = { git = "http://github.com/oxidecomputer/sprockets", rev = "77df31efa5619d0767ffc837ef7468101608aee9" } diff --git a/wicketd/Cargo.toml b/wicketd/Cargo.toml index 83e7bf33ca..26e54eb3bc 100644 --- a/wicketd/Cargo.toml +++ b/wicketd/Cargo.toml @@ -42,7 +42,6 @@ tokio-stream.workspace = true tokio-util.workspace = true tough.workspace = true trust-dns-resolver.workspace = true -snafu.workspace = true toml.workspace = true uuid.workspace = true diff --git a/wicketd/src/config.rs b/wicketd/src/config.rs index 613da904d8..dda0688c3d 100644 --- a/wicketd/src/config.rs +++ b/wicketd/src/config.rs @@ -4,11 +4,10 @@ //! Configuration related types used by wicketd +use camino::{Utf8Path, Utf8PathBuf}; use dropshot::ConfigLogging; use serde::{Deserialize, Serialize}; -use snafu::prelude::*; -use std::path::Path; -use std::path::PathBuf; +use thiserror::Error; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Config { @@ -19,17 +18,32 @@ impl Config { /// Load a `Config` from the given TOML file /// /// This config object can be used to create a wicketd server. - pub fn from_file>(path: P) -> Result { + pub fn from_file>( + path: P, + ) -> Result { let path = path.as_ref(); - let data = std::fs::read_to_string(path).context(IoSnafu { path })?; - toml::from_str(&data).context(ParseSnafu { path }) + let data = std::fs::read_to_string(path).map_err(|error| { + ConfigError::Io { error, path: path.to_owned() } + })?; + toml::from_str(&data).map_err(|error| ConfigError::Parse { + error, + path: path.to_owned(), + }) } } -#[derive(Debug, Snafu)] +#[derive(Debug, Error)] pub enum ConfigError { - #[snafu(display("Failed to read config file: {}", path.display()))] - Io { source: std::io::Error, path: PathBuf }, - #[snafu(display("Failed to parse config file: {}", path.display()))] - Parse { source: toml::de::Error, path: PathBuf }, + #[error("Failed to read config file: {path}")] + Io { + #[source] + error: std::io::Error, + path: Utf8PathBuf, + }, + #[error("Failed to parse config file: {path}")] + Parse { + #[source] + error: toml::de::Error, + path: Utf8PathBuf, + }, }