Simple bug fix

This commit is contained in:
2025-09-27 10:26:13 +02:00
parent 1aa73441c7
commit a265c19870
3 changed files with 39 additions and 5 deletions
+20
View File
@@ -22,4 +22,24 @@ impl Logger {
pub fn error<T: Display>(&self, message: T) {
println!("\x1b[31mERROR\x1b[0m ({}) › {}", self.name, message);
}
pub fn extract<T, E: Display, D: Display>(&self, v: Result<T, E>, m: D) -> Option<T> {
match v {
Ok(a) => Some(a),
Err(e) => {
self.error(format!("{m}: {e}"));
None
}
}
}
pub fn extract_panic<T, E: Display, D: Display>(&self, v: Result<T, E>, m: D) -> T {
match v {
Ok(a) => a,
Err(e) => {
self.error(format!("{m}: {e}"));
panic!()
}
}
}
}