mirror of https://github.com/zkat/miette.git
feat(protocol): Make usafe of ? and return types with Diagnostics more ergonomic
This commit is contained in:
parent
e955321cbd
commit
50238d75a2
|
|
@ -12,7 +12,7 @@ use crate::MietteError;
|
|||
Adds rich metadata to your Error that can be used by [DiagnosticReporter] to print
|
||||
really nice and human-friendly error messages.
|
||||
*/
|
||||
pub trait Diagnostic: std::error::Error + Send + Sync {
|
||||
pub trait Diagnostic: std::error::Error {
|
||||
/// Unique diagnostic code that can be used to look up more information
|
||||
/// about this Diagnostic. Ideally also globally unique, and documented in
|
||||
/// the toplevel crate's documentation for easy searching. Rust path
|
||||
|
|
@ -37,6 +37,14 @@ pub trait Diagnostic: std::error::Error + Send + Sync {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Box<dyn Diagnostic> {}
|
||||
|
||||
impl<T: Diagnostic + 'static> From<T> for Box<dyn Diagnostic> {
|
||||
fn from(diag: T) -> Self {
|
||||
Box::new(diag)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Protocol for [Diagnostic] handlers, which are responsible for actually printing out Diagnostics.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue