summaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/errors.rs
diff options
context:
space:
mode:
authorhar7an <99636919+har7an@users.noreply.github.com>2022-11-12 10:18:15 +0000
committerGitHub <noreply@github.com>2022-11-12 10:18:15 +0000
commit342d1629d08f429a8cb56150401f169c7f1e6b97 (patch)
tree654b3b4fa37d6c4d92475ba5c7b951fa96f35438 /zellij-utils/src/errors.rs
parentb52ca5d13f64a507f6f8b05b3cdd06c94560556a (diff)
Errors: Ignore errors from async when quitting (#1918)
* utils/errors: Fix function order in `to_anyhow` impl for `SendError`. Previously we attached the context to `anyhow!`, which is wrong (because it doesn't create an `Err` type itself) and leads to strange behavior where the error seemingly is immediately panicked upon. Instead, Wrap `anyhow!` into an `Err()` and then attach the context to that. This achieves the intended goal and doesn't lead to premature termination. * server/terminal_bytes: Ignore error in `listen` which occurs when quitting zellij with the `Ctrl+q` keybinding. At the end of the `listen` function we break out of a loop and send a final `Render` instruction to the Screen. However, when quitting zellij as mentioned above, the Screen thread is likely dead already and hence we cannot send it any Instructions. This causes an error in the async tasks of the panes that handle reading the PTY input. If we leave the error unhandled, we will have error messages in the log whenever we quit zellij, even though the application exited normally. Hence, we now send the final `Render` instruction but do not care whether it is sent successfully or not. This is a "workaround" for the fact that we cannot tell whether the application is quitting or not. * server/terminal_bytes: Add FIXME note * changelog: Add PR #1918 don't log errors from async pane threads when quitting zellij
Diffstat (limited to 'zellij-utils/src/errors.rs')
-rw-r--r--zellij-utils/src/errors.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index 1594912b6..46207ab29 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -565,13 +565,14 @@ mod not_wasm {
Err(e) => {
let (msg, context) = e.into_inner();
if *crate::consts::DEBUG_MODE.get().unwrap_or(&true) {
- Err(
- crate::anyhow::anyhow!("failed to send message to channel: {:#?}", msg)
- .context(context.to_string()),
- )
+ Err(crate::anyhow::anyhow!(
+ "failed to send message to channel: {:#?}",
+ msg
+ ))
+ .with_context(|| context.to_string())
} else {
- Err(crate::anyhow::anyhow!("failed to send message to channel")
- .context(context.to_string()))
+ Err(crate::anyhow::anyhow!("failed to send message to channel"))
+ .with_context(|| context.to_string())
}
},
}