summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/panes/tiled_panes/mod.rs
diff options
context:
space:
mode:
authorhar7an <99636919+har7an@users.noreply.github.com>2022-11-08 10:56:23 +0000
committerGitHub <noreply@github.com>2022-11-08 10:56:23 +0000
commit453142775c96752730d7caf85532e616e2aaa719 (patch)
tree607aff5d44ec5894fa98b7e4d108f8bb2815684c /zellij-server/src/panes/tiled_panes/mod.rs
parent39c8d97054ff5a2745df455666dc2decd1fefc0e (diff)
errors: Remove `log::error` in server (#1881)
* server/wasm_vm: Replace `log::error!` with better error logging by means of `non_fatal`. This preserves the original error and allows adding context information on top. Also makes error formatting more uniform across the application. * server/tab: Replace `log::error!` with better error logging by means of `non_fatal`. This preserves the original error and allows adding context information on top. Also makes error formatting more uniform across the application. * server/route: Replace `log::error!` and propagate the error to the caller instead. * server/pty: Replace `log::error!` with better error logging by means of `non_fatal`. This preserves the original error and allows adding context information on top. Also makes error formatting more uniform across the application. Also add per-instruction error context to make it clear what we tried to accomplish when an error occured. * server/panes/tiled_panes: Merge dependencies and sort them into a better order. * server/panes/tiled_panes: Replace `log::error!` with better error logging by means of `non_fatal`. This preserves the original error and allows adding context information on top. Also makes error formatting more uniform across the application. * server/os_input_output: Merge depndencies and sort them into a better order. * server/logging_pipe: Replace `log::error!` with better error logging by means of `non_fatal`. This preserves the original error and allows adding context information on top. Also makes error formatting more uniform across the application. * server/os_io: Remove uses of `log::error` * changelog: Add PR #1881 * server/os_io: Gracefully handle failing resize for terminals IDs that don't exist, instead of propagating the error to the user. * server/lib: Remove leftover log message * server/pty: Log error cause rather than providing a hard-coded error reason which is plain wrong in this context. * server/screen: Remove calls to `log::error!` and change `get_active_tab(_mut)?` to return a `Result` instead of an `Option`. This already makes many places in the code obsolete where previously "failed to get active tab..." was logged manually. Rather than logging, use the `anyhow::Error`s we have, along with all their context information, and log these instead.
Diffstat (limited to 'zellij-server/src/panes/tiled_panes/mod.rs')
-rw-r--r--zellij-server/src/panes/tiled_panes/mod.rs56
1 files changed, 32 insertions, 24 deletions
diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs
index 3bbd872a2..52b287955 100644
--- a/zellij-server/src/panes/tiled_panes/mod.rs
+++ b/zellij-server/src/panes/tiled_panes/mod.rs
@@ -1,29 +1,29 @@
mod pane_resizer;
mod tiled_pane_grid;
-use crate::tab::{Pane, MIN_TERMINAL_HEIGHT, MIN_TERMINAL_WIDTH};
-use tiled_pane_grid::{split, TiledPaneGrid};
-
use crate::{
os_input_output::ServerOsApi,
output::Output,
panes::{ActivePanes, PaneId},
- ui::boundaries::Boundaries,
- ui::pane_contents_and_ui::PaneContentsAndUi,
+ tab::{Pane, MIN_TERMINAL_HEIGHT, MIN_TERMINAL_WIDTH},
+ ui::{boundaries::Boundaries, pane_contents_and_ui::PaneContentsAndUi},
ClientId,
};
-use std::cell::RefCell;
-use std::collections::{BTreeMap, HashMap, HashSet};
-use std::rc::Rc;
-use std::time::Instant;
-use zellij_utils::errors::prelude::*;
+use tiled_pane_grid::{split, TiledPaneGrid};
use zellij_utils::{
data::{ModeInfo, Style},
- input::command::RunCommand,
- input::layout::SplitDirection,
+ errors::prelude::*,
+ input::{command::RunCommand, layout::SplitDirection},
pane_size::{Offset, PaneGeom, Size, SizeInPixels, Viewport},
};
+use std::{
+ cell::RefCell,
+ collections::{BTreeMap, HashMap, HashSet},
+ rc::Rc,
+ time::Instant,
+};
+
macro_rules! resize_pty {
($pane:expr, $os_input:expr) => {
if let PaneId::Terminal(ref pid) = $pane.pid() {
@@ -226,17 +226,18 @@ impl TiledPanes {
*self.display_area.borrow(),
*self.viewport.borrow(),
);
- let result = match direction {
+ match direction {
SplitDirection::Horizontal => {
pane_grid.layout(direction, (*self.display_area.borrow()).cols)
},
SplitDirection::Vertical => {
pane_grid.layout(direction, (*self.display_area.borrow()).rows)
},
- };
- if let Err(e) = &result {
- log::error!("{:?} relayout of the tab failed: {}", direction, e);
}
+ .or_else(|e| Err(anyError::msg(e)))
+ .with_context(|| format!("{:?} relayout of tab failed", direction))
+ .non_fatal();
+
self.set_pane_frames(self.draw_pane_frames);
}
pub fn set_pane_frames(&mut self, draw_pane_frames: bool) {
@@ -492,16 +493,23 @@ impl TiledPanes {
display_area.cols = cols;
},
Err(e) => {
- log::error!("Failed to horizontally resize the tab: {:?}", e);
+ Err::<(), _>(anyError::msg(e))
+ .context("failed to resize tab horizontally")
+ .non_fatal();
+ },
+ };
+ match pane_grid.layout(SplitDirection::Vertical, rows) {
+ Ok(_) => {
+ let row_difference = rows as isize - display_area.rows as isize;
+ viewport.rows = (viewport.rows as isize + row_difference) as usize;
+ display_area.rows = rows;
+ },
+ Err(e) => {
+ Err::<(), _>(anyError::msg(e))
+ .context("failed to resize tab vertically")
+ .non_fatal();
},
};
- if pane_grid.layout(SplitDirection::Vertical, rows).is_ok() {
- let row_difference = rows as isize - display_area.rows as isize;
- viewport.rows = (viewport.rows as isize + row_difference) as usize;
- display_area.rows = rows;
- } else {
- log::error!("Failed to vertically resize the tab!!!");
- }
}
self.set_pane_frames(self.draw_pane_frames);
}