summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-03-03 23:00:19 -0500
committerLLLL Colonq <llll@colonq>2025-03-03 23:00:19 -0500
commit22fbeca88a781aca7bcc965ac8189244497671d6 (patch)
treea4c6e0b26012f151b68539a83a09fba9b6529636
parent901fe3013ea86242f403d6dc867dd45f12700b7a (diff)
Add some helpers for error handling
-rw-r--r--src/lib.rs2
-rw-r--r--src/utils.rs6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 49a3da3..3c00719 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -13,7 +13,7 @@ pub mod audio;
pub mod net;
pub mod save;
-pub use utils::Erm;
+pub use utils::{erm, Erm};
pub use anyhow::Context as ErmContext;
#[cfg(target_arch = "wasm32")]
diff --git a/src/utils.rs b/src/utils.rs
index f5ce271..b2d1868 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -2,7 +2,11 @@ use serde::{Serialize, Deserialize};
pub type Erm<T> = anyhow::Result<T>;
-#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
+pub fn erm<E, T>(e: E) -> Erm<T> where E: std::error::Error + std::marker::Send + std::marker::Sync + 'static {
+ Err(anyhow::Error::from(e))
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum Cardinal {
North,
South,