mirror of https://github.com/zkat/miette.git
refactor(miette): reuse `DiagnosticError` in `protocol.rs`
This commit is contained in:
parent
6d521a512a
commit
53c8330f21
|
|
@ -12,7 +12,7 @@ use std::{
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::MietteError;
|
use crate::{DiagnosticError, MietteError};
|
||||||
|
|
||||||
/// Adds rich metadata to your Error that can be used by
|
/// Adds rich metadata to your Error that can be used by
|
||||||
/// [`Report`](crate::Report) to print really nice and human-friendly error
|
/// [`Report`](crate::Report) to print really nice and human-friendly error
|
||||||
|
|
@ -174,18 +174,7 @@ impl From<String> for Box<dyn Diagnostic + Send + Sync> {
|
||||||
|
|
||||||
impl From<Box<dyn std::error::Error + Send + Sync>> for Box<dyn Diagnostic + Send + Sync> {
|
impl From<Box<dyn std::error::Error + Send + Sync>> for Box<dyn Diagnostic + Send + Sync> {
|
||||||
fn from(s: Box<dyn std::error::Error + Send + Sync>) -> Self {
|
fn from(s: Box<dyn std::error::Error + Send + Sync>) -> Self {
|
||||||
#[derive(thiserror::Error)]
|
Box::new(DiagnosticError(s))
|
||||||
#[error(transparent)]
|
|
||||||
struct BoxedDiagnostic(Box<dyn std::error::Error + Send + Sync>);
|
|
||||||
impl fmt::Debug for BoxedDiagnostic {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt::Debug::fmt(&self.0, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Diagnostic for BoxedDiagnostic {}
|
|
||||||
|
|
||||||
Box::new(BoxedDiagnostic(s))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue