Skip to content

Commit

Permalink
[refactor]: ignore report locations
Browse files Browse the repository at this point in the history
address hyperledger#4456 (comment)

Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com>
  • Loading branch information
0x009922 committed Apr 22, 2024
1 parent ccd0308 commit 6f460e6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cli/src/main.rs
Expand Up @@ -21,18 +21,14 @@ enum MainError {
async fn main() -> error_stack::Result<(), MainError> {
let args = Args::parse();

configure_reports(&args);

if args.trace_config {
iroha_config::enable_tracing()
.change_context(MainError::TraceConfigSetup)
.attach_printable("was enabled by `--trace-config` argument")?;
}

error_stack::Report::set_color_mode(if args.terminal_colors {
error_stack::fmt::ColorMode::Color
} else {
error_stack::fmt::ColorMode::None
});

let (config, logger_config, genesis) =
iroha::read_config_and_genesis(&args).change_context(MainError::Config).attach_printable_lazy(|| {
args.config.as_ref().map_or_else(
Expand Down Expand Up @@ -64,3 +60,19 @@ async fn main() -> error_stack::Result<(), MainError> {

Ok(())
}

/// Configures globals of [`error_stack::Report`]
fn configure_reports(args: &Args) {
use std::panic::Location;

use error_stack::{fmt::ColorMode, Report};

Report::set_color_mode(if args.terminal_colors {
ColorMode::Color
} else {
ColorMode::None
});

// neither devs nor users benefit from it
Report::install_debug_hook::<Location>(|_, _| {});
}

0 comments on commit 6f460e6

Please sign in to comment.