Skip to content

Commit

Permalink
refactor error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Qyriad committed May 25, 2022
1 parent d2e2f7a commit 74a985c
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 148 deletions.
37 changes: 37 additions & 0 deletions Cargo.lock

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

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ name = "bmputil"
version = "0.1.0"
edition = "2021"

[features]
# Enable backtraces for errors. Requires nightly toolchain.
# Automatically enabled if detect-backtrace feature is enabled (default).
backtrace = []
# Autoamtically detect if backtrace feature should be enabled by detecting the channel we're being compiled on.
detect-backtrace = []
default = ["detect-backtrace"]

[dependencies]
clap = { version = "3.0", default-features = false, features = ["std", "color"] }
env_logger = "0.9"
dfu-core = { version = "0.2", features = ["std"] }
dfu-libusb = "0.2"
rusb = "0.9"
log = "0.4"
const_format = "0.2"
anyhow = "1.0"
thiserror = "1.0"
indicatif = "0.16"

[build-dependencies]
rustc_version = "0.4"

[profile.release]
lto = "fat"

Expand Down
23 changes: 23 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

use rustc_version::{version_meta, Channel};

fn main()
{
// If detect-backtrace is enabled (default), detect if we're on nightly or not.
// If we're on nightly, enable backtraces automatically.
match std::env::var_os("CARGO_FEATURE_DETECT_BACKTRACE") {
Some(_val) => {
match version_meta() {
Ok(version_meta) => {
if version_meta.channel == Channel::Nightly {
println!("cargo:rustc-cfg=feature=\"backtrace\"");
}
},
Err(e) => {
println!("cargo:warning=error detecting rustc version: {}", e);
}
}
},
None => (),
}
}
Loading

0 comments on commit 74a985c

Please sign in to comment.