-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reporting): add support for different targets and formats
closes #1 Signed-off-by: azjezz <[email protected]>
- Loading branch information
Showing
25 changed files
with
897 additions
and
267 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,9 @@ | ||
#[macro_export] | ||
macro_rules! enum_variants { | ||
($e: ty) => {{ | ||
use clap::builder::TypedValueParser; | ||
use strum::VariantNames; | ||
|
||
clap::builder::PossibleValuesParser::new(<$e>::VARIANTS).map(|s| s.parse::<$e>().unwrap()) | ||
}}; | ||
} |
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
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,65 @@ | ||
use codespan_reporting::files::Error as FilesError; | ||
use serde_json::Error as JsonError; | ||
use std::io::Error as IoError; | ||
|
||
use mago_source::error::SourceError; | ||
|
||
#[derive(Debug)] | ||
pub enum ReportingError { | ||
SourceError(SourceError), | ||
JsonError(JsonError), | ||
FilesError(FilesError), | ||
IoError(IoError), | ||
InvalidTarget(String), | ||
InvalidFormat(String), | ||
} | ||
|
||
impl std::fmt::Display for ReportingError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::SourceError(error) => write!(f, "source error: {}", error), | ||
Self::JsonError(error) => write!(f, "json error: {}", error), | ||
Self::FilesError(error) => write!(f, "files error: {}", error), | ||
Self::IoError(error) => write!(f, "io error: {}", error), | ||
Self::InvalidTarget(target) => write!(f, "invalid target: {}", target), | ||
Self::InvalidFormat(format) => write!(f, "invalid format: {}", format), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for ReportingError { | ||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { | ||
match self { | ||
Self::SourceError(error) => Some(error), | ||
Self::JsonError(error) => Some(error), | ||
Self::FilesError(error) => Some(error), | ||
Self::IoError(error) => Some(error), | ||
Self::InvalidTarget(_) => None, | ||
Self::InvalidFormat(_) => None, | ||
} | ||
} | ||
} | ||
|
||
impl From<SourceError> for ReportingError { | ||
fn from(error: SourceError) -> Self { | ||
Self::SourceError(error) | ||
} | ||
} | ||
|
||
impl From<JsonError> for ReportingError { | ||
fn from(error: JsonError) -> Self { | ||
Self::JsonError(error) | ||
} | ||
} | ||
|
||
impl From<FilesError> for ReportingError { | ||
fn from(error: FilesError) -> Self { | ||
Self::FilesError(error) | ||
} | ||
} | ||
|
||
impl From<IoError> for ReportingError { | ||
fn from(error: IoError) -> Self { | ||
Self::IoError(error) | ||
} | ||
} |
Oops, something went wrong.