forked from alemi/upub
feat: added simpler ways to ignore+log errors
This commit is contained in:
parent
0ec636a868
commit
95eaa9596c
2 changed files with 26 additions and 0 deletions
25
src/errors.rs
Normal file
25
src/errors.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
pub trait LoggableError {
|
||||
fn info_failed(self, msg: &str);
|
||||
fn warn_failed(self, msg: &str);
|
||||
fn err_failed(self, msg: &str);
|
||||
}
|
||||
|
||||
impl<T, E: std::error::Error> LoggableError for Result<T, E> {
|
||||
fn info_failed(self, msg: &str) {
|
||||
if let Err(e) = self {
|
||||
tracing::info!("{} : {}", msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
fn warn_failed(self, msg: &str) {
|
||||
if let Err(e) = self {
|
||||
tracing::warn!("{} : {}", msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
fn err_failed(self, msg: &str) {
|
||||
if let Err(e) = self {
|
||||
tracing::error!("{} : {}", msg, e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ pub mod migrations;
|
|||
pub mod activitystream;
|
||||
pub mod activitypub;
|
||||
pub mod server;
|
||||
pub mod errors;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use sea_orm::{ConnectOptions, Database, EntityTrait, IntoActiveModel};
|
||||
|
|
Loading…
Reference in a new issue