Simple bug fix
This commit is contained in:
@@ -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!()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user