Skip to content

Commit

Permalink
Use eyre for error handling
Browse files Browse the repository at this point in the history
Miette is very good but for our use cases, wrapping lib errors with
.into_diagnostic() calls is very verbose.
  • Loading branch information
Juuxel committed Jul 22, 2024
1 parent ebb13de commit 0fc1e9c
Show file tree
Hide file tree
Showing 18 changed files with 203 additions and 197 deletions.
192 changes: 103 additions & 89 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2021"
members = ["version_resolver"]

[workspace.dependencies]
miette = "7.1"
reqwest = "0.12"
xml_dom = "0.2.6"
wasm-bindgen = "0.2.92"
Expand All @@ -20,6 +19,8 @@ tokio = { version = "1", features = ["full"] }
rfd = "0.14"
cliclack = "0.3.2"
clap = { version = "4.5", features = ["derive"] }
eyre = { version = "0.6" }
color-eyre = { version = "0.6" }

[workspace.dependencies.web-sys]
version = "0.3.64"
Expand All @@ -42,7 +43,7 @@ features = [
crate-type = ["cdylib", "rlib"]

[dependencies]
miette = { workspace = true }
eyre = { workspace = true }
reqwest = { workspace = true }
futures = "0.3"
zip = { version = "2.1.3", default-features = false, features = ["deflate"] }
Expand All @@ -53,7 +54,7 @@ version_resolver = { path = "version_resolver" }
bytes = "1.6"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
miette = { workspace = true, features = ["fancy"] }
color-eyre = { workspace = true }
tokio = { workspace = true }
cliclack = { workspace = true }
clap = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions src/app/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::tap::Tap;
use crate::templates::*;
use crate::{MappingSet, ProjectType};
use bytes::Bytes;
use eyre::Result;
use futures::future::join_all;
use futures::{join, FutureExt};
use miette::{IntoDiagnostic, Result};
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
Expand Down Expand Up @@ -63,7 +63,7 @@ pub async fn generate(app: &super::GeneratorApp, filer_provider: &impl crate::fi
context.put("PLUGIN_VERSION", crate::versions::PLUGIN_VERSION);

// Setup version resolving
let client = Arc::new(reqwest::ClientBuilder::new().build().into_diagnostic()?);
let client = Arc::new(reqwest::ClientBuilder::new().build()?);
let versions = crate::app::versions::get_version_index(client.clone(), &game_version).await?;
let mut files: Vec<Pin<Box<dyn Future<Output = Result<Vec<FileData>>>>>> =
vec![Box::pin(shared::shared_files(client.clone()))];
Expand Down
Loading

0 comments on commit 0fc1e9c

Please sign in to comment.