diff --git a/crates/dtmm/src/ui/window/dialog.rs b/crates/dtmm/src/ui/window/dialog.rs index 11df4d5..06a6c02 100644 --- a/crates/dtmm/src/ui/window/dialog.rs +++ b/crates/dtmm/src/ui/window/dialog.rs @@ -7,14 +7,11 @@ use crate::ui::widget::button::Button; const WINDOW_SIZE: (f64, f64) = (600., 250.); -/// Show an error dialog. -/// The title and message are extracted from the error chain in the given `Report`. pub fn error(err: Report, _parent: WindowHandle) -> WindowDesc { let (title, msg) = { let count = err.chain().count(); if count == 1 { - // If there is only one error, that's all we can show. ( String::from("An error occurred!"), err.root_cause().to_string(), @@ -23,20 +20,13 @@ pub fn error(err: Report, _parent: WindowHandle) -> WindowDesc { let first = err.chain().next().unwrap(); let root = err.root_cause(); - // If there is more than one error in the chain we want to show - // - The first one: This will describe the overall operation that failed - // - The root cause: The actual thing that failed (e.g. 'No such file or directory') - // - The one before the root cause: With diligent `wrap_err` usage, this will provide - // context to the root cause (e.g. the file name we failed to access) - // - // If there are only two errors, the first one is also the context to the root cause. if count > 2 { // The second to last one, the context to the root cause let context = err.chain().nth(count - 2).unwrap(); (format!("{first}!"), format!("{}: {}", context, root)) } else { - ("An error occurred!".to_string(), format!("{}: {}", first, root)) + (format!("{first}!"), root.to_string()) } } }; diff --git a/crates/dtmm/src/util/log.rs b/crates/dtmm/src/util/log.rs index fa4a643..09fc9a6 100644 --- a/crates/dtmm/src/util/log.rs +++ b/crates/dtmm/src/util/log.rs @@ -56,7 +56,7 @@ impl std::io::Write for ChannelWriter { } pub fn create_tracing_subscriber(tx: UnboundedSender>, level: Option) { - let mut env_layer = if let Some(level) = level { + let env_layer = if let Some(level) = level { EnvFilter::from(level) } else if cfg!(debug_assertions) { EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")) @@ -64,18 +64,6 @@ pub fn create_tracing_subscriber(tx: UnboundedSender>, level: Option