-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(errors)!: refactored errors
- Loading branch information
Showing
7 changed files
with
129 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::models::frames::expanded_frame::FrameProcessingConfig; | ||
use std::fmt::Display; | ||
use timsrust::TimsRustError; | ||
|
||
#[derive(Debug)] | ||
pub enum TimsqueryError { | ||
DataReadingError(DataReadingError), | ||
DataProcessingError(DataProcessingError), | ||
Other(String), | ||
} | ||
|
||
pub type Result<T> = std::result::Result<T, TimsqueryError>; | ||
|
||
impl Display for TimsqueryError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{:?}", self) | ||
} | ||
} | ||
|
||
impl TimsqueryError { | ||
pub fn custom(msg: impl Display) -> Self { | ||
Self::Other(msg.to_string()) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum DataReadingError { | ||
UnsupportedDataError(UnsupportedDataError), | ||
TimsRustError(TimsRustError), // Why doesnt timsrust error derive clone? | ||
} | ||
|
||
impl From<UnsupportedDataError> for DataReadingError { | ||
fn from(e: UnsupportedDataError) -> Self { | ||
DataReadingError::UnsupportedDataError(e) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum UnsupportedDataError { | ||
NoMS2DataError, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum DataProcessingError { | ||
CentroidingError(FrameProcessingConfig), | ||
} | ||
|
||
impl<T: Into<DataReadingError>> From<T> for TimsqueryError { | ||
fn from(e: T) -> Self { | ||
TimsqueryError::DataReadingError(e.into()) | ||
} | ||
} | ||
|
||
impl<T: Into<TimsRustError>> From<T> for DataReadingError { | ||
fn from(e: T) -> Self { | ||
DataReadingError::TimsRustError(e.into()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.