From f56ac321f4f6a36b011564d9bc39573eb4770dd0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 18 May 2024 22:16:17 +0100 Subject: [PATCH] chore: remove dependency on terrors --- Cargo.toml | 3 --- crates/config/Cargo.toml | 1 - crates/git/Cargo.toml | 1 - crates/server/Cargo.toml | 3 +-- crates/server/src/config/load.rs | 18 ++++++++---------- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2e2380f9..f601e7c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,9 +66,6 @@ derive_more = { version = "1.0.0-beta.6", features = [ "from", ] } -# error handling -terrors = "0.3" - # file watcher inotify = "0.10" diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 56438452..727e1a9c 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -46,7 +46,6 @@ secrecy = { workspace = true } # # # error handling derive_more = { workspace = true } -# terrors = { workspace = true } # # # file watcher # inotify = { workspace = true } diff --git a/crates/git/Cargo.toml b/crates/git/Cargo.toml index 201a0ee1..35ed0ee9 100644 --- a/crates/git/Cargo.toml +++ b/crates/git/Cargo.toml @@ -48,7 +48,6 @@ secrecy = { workspace = true } # error handling derive_more = { workspace = true } -# terrors = { workspace = true } # # file watcher # inotify = { workspace = true } diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index 3c5e5d8f..b6730913 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -47,9 +47,8 @@ bytes = { workspace = true } ulid = { workspace = true } warp = { workspace = true } -# error handling +# boilerplate derive_more = { workspace = true } -terrors = { workspace = true } # file watcher inotify = { workspace = true } diff --git a/crates/server/src/config/load.rs b/crates/server/src/config/load.rs index 62693464..68d0ea59 100644 --- a/crates/server/src/config/load.rs +++ b/crates/server/src/config/load.rs @@ -1,25 +1,23 @@ use git_next_config::{BranchName, RepoConfig}; use git_next_git::RepoDetails; -use terrors::OneOf; use tracing::error; use crate::gitforge::{self, ForgeFileError}; -pub async fn load( - details: &RepoDetails, - forge: &gitforge::Forge, -) -> Result> { +pub async fn load(details: &RepoDetails, forge: &gitforge::Forge) -> Result { let contents = forge .file_contents_get(&details.branch, ".git-next.toml") - .await - .map_err(OneOf::new)?; - let config = RepoConfig::load(&contents).map_err(OneOf::new)?; - let config = validate(config, forge).await.map_err(OneOf::new)?; + .await?; + let config = RepoConfig::load(&contents)?; + let config = validate(config, forge).await?; Ok(config) } -#[derive(Debug)] +#[derive(Debug, derive_more::From, derive_more::Display)] pub enum Error { + File(ForgeFileError), + Config(crate::config::Error), + Toml(toml::de::Error), Forge(gitforge::ForgeBranchError), BranchNotFound(BranchName), }