Skip to content

Commit

Permalink
add log method to error
Browse files Browse the repository at this point in the history
  • Loading branch information
CheatCod committed Jul 18, 2023
1 parent 67d2b60 commit 36c3cfa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use serde_json::json;
use thiserror::Error;
use ts_rs::TS;

use crate::error;

#[derive(Debug, Clone, Deserialize, Serialize, TS)]
#[ts(export)]
pub enum ErrorKind {
Expand All @@ -27,6 +29,15 @@ pub struct Error {
pub source: color_eyre::Report,
}


impl Error {
pub fn log(self) -> Self {
error!("An error occurred ({kind}): {source}", kind = self.kind, source = self.source);
self
}
}


impl Display for ErrorKind {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down

0 comments on commit 36c3cfa

Please sign in to comment.