aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/lib.rs
diff options
context:
space:
mode:
authorhar7an <99636919+har7an@users.noreply.github.com>2022-09-09 13:21:03 +0000
committerGitHub <noreply@github.com>2022-09-09 13:21:03 +0000
commit99e2bef8c68bd166cf89e90c8ffe8c02272ab4d3 (patch)
tree1eb34d081e8d96c9f6d49f26beb8e0d97666aa6e /zellij-utils/src/lib.rs
parentchore(version): bump development version (diff)
downloadsl0ppij-99e2bef8c68bd166cf89e90c8ffe8c02272ab4d3.tar.gz
sl0ppij-99e2bef8c68bd166cf89e90c8ffe8c02272ab4d3.tar.xz
sl0ppij-99e2bef8c68bd166cf89e90c8ffe8c02272ab4d3.zip
Feature: Better error handling/reporting (#1670)
* utils: re-export "anyhow" unconditionally even for wasm targets. * utils/errors: Share wasm-compatible code and move everything that can't run in wasm into a separate submodule. * utils: Share "errors" module unconditionally The module is now structured such that all code incompatible with wasm targets lives in its own submodule that isn't included when compiling for wasm targets. * utils/errors: Add "Help wanted" doc section that informs the reader about the endeavour to improve error handling throughout the zellij code base. * plugins: Handle errors returned by `zellij_tile` now that the panic calls have been removed. * utils/errors: Extend `anyhow::Result` with traits that allow for easy/concise logging of `anyhow::Result` types and panicking the application when they are fatal or non-fatal. * utils/errors: Fix doctest * utils/errors: Add prelude that applications can import to conveniently access the error handling functionality part of the module. Re-exports some parts and macros from anyhow and the `LoggableError` and `FatalError` traits. * server/screen: Adopt error handling and make all fallible functions from the public API return a `Result`. Append error contexts in all functions that can come across error types to allow tracing where an error originates and what lead there. * server/lib: Catch errors from `screen` and make them `fatal`. This will log the errors first, before unwrapping on the error type and panicking the application. * server/unit/screen: Fix unit tests and unwrap on the `Result` types introduced from the new error handling. * utils/errors: Track error source in calls to `fatal`, so we keep track of the location where the panic really originates. Otherwise, any call to `fatal` will show the code in `errors` as source, which of course isn't true. Also change the error formatting and do not call `to_log` for fatal errors anymore, because the panic is already logged and contains much more information. * utils/errors: Update `FatalError` docs * plugins: Undo accidental modifications * utils/errors: Improve module docs explain some error handling facilities and the motivation behind using them. * server/screen: Remove `Result` from Infallible functions that are part of the public API.
Diffstat (limited to 'zellij-utils/src/lib.rs')
-rw-r--r--zellij-utils/src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/zellij-utils/src/lib.rs b/zellij-utils/src/lib.rs
index 3cff1f04..e871aeee 100644
--- a/zellij-utils/src/lib.rs
+++ b/zellij-utils/src/lib.rs
@@ -2,6 +2,7 @@ pub mod cli;
pub mod consts;
pub mod data;
pub mod envs;
+pub mod errors;
pub mod input;
pub mod pane_size;
pub mod position;
@@ -12,14 +13,14 @@ pub mod shared;
#[cfg(not(target_family = "wasm"))]
pub mod channels; // Requires async_std
#[cfg(not(target_family = "wasm"))]
-pub mod errors; // Requires async_std (via channels)
-#[cfg(not(target_family = "wasm"))]
pub mod ipc; // Requires interprocess
#[cfg(not(target_family = "wasm"))]
pub mod logging; // Requires log4rs
#[cfg(not(target_family = "wasm"))]
pub use ::{
- anyhow, async_std, clap, interprocess, lazy_static, libc, nix, regex, serde, serde_yaml,
- signal_hook, tempfile, termwiz, vte,
+ async_std, clap, interprocess, lazy_static, libc, nix, regex, serde, serde_yaml, signal_hook,
+ tempfile, termwiz, vte,
};
+
+pub use anyhow;