diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 1fd0e9aa668f0a..a0c9ab47943fbb 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -9,6 +9,7 @@ use std::time::{Duration, Instant}; use calloop::generic::{FdWrapper, Generic}; use calloop::{EventLoop, LoopHandle, RegistrationToken}; +use anyhow::Context as _; use collections::HashMap; use http_client::Url; use smallvec::SmallVec; @@ -1417,9 +1418,10 @@ impl LinuxClient for X11Client { ..Default::default() }, ) - .expect("failed to change window cursor") - .check() - .unwrap(); + .anyhow() + .and_then(|cookie| cookie.check().anyhow()) + .context("setting cursor style") + .log_err(); } fn open_uri(&self, uri: &str) { diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs index fe3f7ef9a04836..777b8b60dcdffd 100644 --- a/crates/util/src/util.rs +++ b/crates/util/src/util.rs @@ -206,6 +206,9 @@ pub trait ResultExt { /// Assert that this result should never be an error in development or tests. fn debug_assert_ok(self, reason: &str) -> Self; fn warn_on_err(self) -> Option; + fn anyhow(self) -> anyhow::Result + where + E: Into; } impl ResultExt for Result @@ -243,6 +246,13 @@ where } } } + + fn anyhow(self) -> anyhow::Result + where + E: Into, + { + self.map_err(Into::into) + } } fn log_error_with_caller(caller: core::panic::Location<'_>, error: E, level: log::Level)