mirror of https://github.com/zkat/miette.git
DynamicDiagnostic -> MietteDiagnostic
This commit is contained in:
parent
e6d2eede61
commit
ab20069e85
|
|
@ -619,12 +619,12 @@
|
||||||
//! [`ariadne`](https://github.com/zesterer/ariadne), which is MIT licensed.
|
//! [`ariadne`](https://github.com/zesterer/ariadne), which is MIT licensed.
|
||||||
pub use miette_derive::*;
|
pub use miette_derive::*;
|
||||||
|
|
||||||
pub use dynamic_diagnostic::*;
|
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
pub use eyreish::*;
|
pub use eyreish::*;
|
||||||
#[cfg(feature = "fancy-no-backtrace")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
pub use handler::*;
|
pub use handler::*;
|
||||||
pub use handlers::*;
|
pub use handlers::*;
|
||||||
|
pub use miette_diagnostic::*;
|
||||||
pub use named_source::*;
|
pub use named_source::*;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy")]
|
||||||
pub use panic::*;
|
pub use panic::*;
|
||||||
|
|
@ -632,7 +632,6 @@ pub use protocol::*;
|
||||||
|
|
||||||
mod chain;
|
mod chain;
|
||||||
mod diagnostic_chain;
|
mod diagnostic_chain;
|
||||||
mod dynamic_diagnostic;
|
|
||||||
mod error;
|
mod error;
|
||||||
mod eyreish;
|
mod eyreish;
|
||||||
#[cfg(feature = "fancy-no-backtrace")]
|
#[cfg(feature = "fancy-no-backtrace")]
|
||||||
|
|
@ -640,6 +639,7 @@ mod handler;
|
||||||
mod handlers;
|
mod handlers;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub mod macro_helpers;
|
pub mod macro_helpers;
|
||||||
|
mod miette_diagnostic;
|
||||||
mod named_source;
|
mod named_source;
|
||||||
#[cfg(feature = "fancy")]
|
#[cfg(feature = "fancy")]
|
||||||
mod panic;
|
mod panic;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use crate::Diagnostic;
|
||||||
|
|
||||||
/// Diagnostic that can be created at runtime.
|
/// Diagnostic that can be created at runtime.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct DynamicDiagnostic {
|
pub struct MietteDiagnostic {
|
||||||
/// Displayed diagnostic description
|
/// Displayed diagnostic description
|
||||||
pub description: String,
|
pub description: String,
|
||||||
/// Unique diagnostic code to look up more information
|
/// Unique diagnostic code to look up more information
|
||||||
|
|
@ -18,15 +18,15 @@ pub struct DynamicDiagnostic {
|
||||||
pub code: Option<String>,
|
pub code: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for DynamicDiagnostic {
|
impl Display for MietteDiagnostic {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{}", &self.description)
|
write!(f, "{}", &self.description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for DynamicDiagnostic {}
|
impl Error for MietteDiagnostic {}
|
||||||
|
|
||||||
impl Diagnostic for DynamicDiagnostic {
|
impl Diagnostic for MietteDiagnostic {
|
||||||
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||||
self.code
|
self.code
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -35,14 +35,14 @@ impl Diagnostic for DynamicDiagnostic {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DynamicDiagnostic {
|
impl MietteDiagnostic {
|
||||||
/// Create a new dynamic diagnostic with the given description.
|
/// Create a new dynamic diagnostic with the given description.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use miette::{Diagnostic, DynamicDiagnostic};
|
/// use miette::{Diagnostic, MietteDiagnostic};
|
||||||
///
|
///
|
||||||
/// let diag = DynamicDiagnostic::new("Oops, something went wrong!");
|
/// let diag = MietteDiagnostic::new("Oops, something went wrong!");
|
||||||
/// assert_eq!(diag.to_string(), "Oops, something went wrong!");
|
/// assert_eq!(diag.to_string(), "Oops, something went wrong!");
|
||||||
/// assert_eq!(diag.description, "Oops, something went wrong!");
|
/// assert_eq!(diag.description, "Oops, something went wrong!");
|
||||||
/// ```
|
/// ```
|
||||||
|
|
@ -57,9 +57,9 @@ impl DynamicDiagnostic {
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use miette::{Diagnostic, DynamicDiagnostic};
|
/// use miette::{Diagnostic, MietteDiagnostic};
|
||||||
///
|
///
|
||||||
/// let diag = DynamicDiagnostic::new("Oops, something went wrong!").with_code("foo::bar::baz");
|
/// let diag = MietteDiagnostic::new("Oops, something went wrong!").with_code("foo::bar::baz");
|
||||||
/// assert_eq!(diag.description, "Oops, something went wrong!");
|
/// assert_eq!(diag.description, "Oops, something went wrong!");
|
||||||
/// assert_eq!(diag.code, Some("foo::bar::baz".to_string()));
|
/// assert_eq!(diag.code, Some("foo::bar::baz".to_string()));
|
||||||
/// ```
|
/// ```
|
||||||
Loading…
Reference in New Issue