Capture terminal errors and show them in a message box

This helps diagnose problems where stderr is not visible.
Let's also capture them to the `log` stream too, and clarify
toml parsing errors, and fix the underlying problem with
ssh_domains not being allowed to be left unspecified.
This commit is contained in:
Wez Furlong committed 2019-07-30 08:45:39 -07:00
1 parent a7722beb0a
commit 348575854d
2 files changed
+24 -8

No files matched your search

+3 -2
View File
@@ -83,6 +83,7 @@ pub struct Config {
#[serde(default = "UnixDomain::default_unix_domains")]
pub unix_domains: Vec<UnixDomain>,
#[serde(default)]
pub ssh_domains: Vec<SshDomain>,
/// When running in server mode, defines configuration for
@@ -803,7 +804,7 @@ impl Config {
Ok(file) => file,
Err(err) => match err.kind() {
std::io::ErrorKind::NotFound => continue,
_ => bail!("Error opening {}: {:?}", p.display(), err),
_ => bail!("Error opening {}: {}", p.display(), err),
},
};
@@ -811,7 +812,7 @@ impl Config {
file.read_to_string(&mut s)?;
let cfg: Self = toml::from_str(&s)
.map_err(|e| format_err!("Error parsing TOML from {}: {:?}", p.display(), e))?;
.map_err(|e| format_err!("Error parsing TOML from {}: {}", p.display(), e))?;
// Compute but discard the key bindings here so that we raise any
// problems earlier than we use them.
+21 -6
View File
@@ -244,13 +244,21 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Fallibl
}
fn main() -> Result<(), Error> {
let opts = Opt::from_args();
let config = Arc::new(if opts.skip_config {
config::Config::default_config()
} else {
config::Config::load()?
});
let result = run();
if let Err(e) = &result {
let message = e.to_string();
tinyfiledialogs::message_box_ok(
"wezterm",
&message,
tinyfiledialogs::MessageBoxIcon::Error,
);
log::error!("{}", message);
}
result
}
fn run() -> Result<(), Error> {
// This is a bit gross.
// In order to not to automatically open a standard windows console when
// we run, we use the windows_subsystem attribute at the top of this
@@ -285,6 +293,13 @@ fn main() -> Result<(), Error> {
};
pretty_env_logger::init();
let opts = Opt::from_args();
let config = Arc::new(if opts.skip_config {
config::Config::default_config()
} else {
config::Config::load()?
});
match opts
.cmd
.as_ref()