Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to color-eyre for error reporting #654

Merged
merged 3 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/bors.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
block_labels = ["needs-decision"]
delete_merged_branches = true
required_approvals = 1
use_codeowners = true
status = ["conclusion"]
timeout_sec = 21600
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- #654 - Use color-eyre for error reporting
- #658 - Upgrade dependencies
- #647 - Add `mips64-unknown-linux-muslabi64` and `mips64el-unknown-linux-muslabi64` support
- #652 - Allow trying individual targets via bors.
Expand Down
130 changes: 121 additions & 9 deletions Cargo.lock

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

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ edition = "2018"

[dependencies]
atty = "0.2"
error-chain = "0.12"
color-eyre = "0.6"
eyre = "0.6"
home = "0.5"
lazy_static = "1.0"
libc = "0.2.104"
lazy_static = "1"
rustc_version = "0.4"
toml = "0.5"
which = { version = "4", default_features = false }
shell-escape = "0.1.4"
serde_json = "1.0.48"
shell-escape = "0.1"
serde_json = "1"

[target.'cfg(not(windows))'.dependencies]
nix = "0.23"
libc = "0.2"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.7", features = ["winbase"] }
winapi = { version = "0.3", features = ["winbase"] }

[profile.release]
lto = true
2 changes: 1 addition & 1 deletion src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Root {

/// Cargo project root
pub fn root() -> Result<Option<Root>> {
let cd = env::current_dir().chain_err(|| "couldn't get current directory")?;
let cd = env::current_dir().wrap_err("couldn't get current directory")?;

let mut dir = &*cd;
loop {
Expand Down
39 changes: 19 additions & 20 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{Result, Target, Toml};

use crate::errors::*;
use std::collections::HashMap;
use std::env;

#[derive(Debug)]
struct Environment(&'static str, Option<HashMap<&'static str, &'static str>>);

Expand Down Expand Up @@ -42,22 +44,20 @@ impl Environment {
self.get_build_var("XARGO"),
self.get_target_var(target, "XARGO"),
);
let build_env =
if let Some(value) = build_xargo {
Some(value.parse::<bool>().map_err(|_| {
format!("error parsing {} from XARGO environment variable", value)
})?)
} else {
None
};
let target_env =
if let Some(value) = target_xargo {
Some(value.parse::<bool>().map_err(|_| {
format!("error parsing {} from XARGO environment variable", value)
})?)
} else {
None
};
let build_env = if let Some(value) = build_xargo {
Some(value.parse::<bool>().wrap_err_with(|| {
format!("error parsing {} from XARGO environment variable", value)
})?)
} else {
None
};
let target_env = if let Some(value) = target_xargo {
Some(value.parse::<bool>().wrap_err_with(|| {
format!("error parsing {} from XARGO environment variable", value)
})?)
} else {
None
};

Ok((build_env, target_env))
}
Expand Down Expand Up @@ -279,10 +279,9 @@ mod tests {

fn toml(content: &str) -> Result<crate::Toml> {
Ok(crate::Toml {
table: if let Ok(toml::Value::Table(table)) = content.parse() {
table
} else {
return Err("couldn't parse toml as TOML table".into());
table: match content.parse().wrap_err("couldn't parse toml")? {
toml::Value::Table(table) => table,
_ => eyre::bail!("couldn't parse toml as TOML table"),
},
})
}
Expand Down
Loading