From 73296ede1fc7b1abde65546a71aef5a988c21e8d Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sun, 15 Nov 2026 22:30:48 -0700 Subject: multi-threaded. more dependencies :( the clock runs now! some unfortunate reliance on exact sequencing, which needs to be cleaned up Force-Push: yes Change-Id: I833dd0dd5047e3c2f04203e80e3fd722e36bf252 --- src/error.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 81c69e5..8537d2e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,12 +5,37 @@ pub struct Error(String); pub type Result = std::result::Result; +impl Error { + pub fn log(&self) { + println!("Error: {}", self); + } +} + + impl Display for Error { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!(formatter, "Error: {}", self.0) } } +impl From> for Error { + fn from(error: std::sync::PoisonError) -> Error { + Error(format!("Lock poisoned: {}", error)) + } +} + +impl From for Error { + fn from(error: async_channel::RecvError) -> Error { + Error(format!("Channel receive error: {}", error)) + } +} + +impl From> for Error { + fn from(error: async_channel::SendError) -> Error { + Error(format!("Channel send error: {}", error)) + } +} + impl From for Error { fn from(error: xcb::Error) -> Error { match error { @@ -33,3 +58,12 @@ impl From for Error { } +pub fn log_and_ignore_errors>( + result: std::result::Result) +{ + match result { + Ok(_) => (), + Err(error) => Into::::into(error).log() + } +} + -- cgit 1.4.1