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.
|
||||
pub use miette_derive::*;
|
||||
|
||||
pub use dynamic_diagnostic::*;
|
||||
pub use error::*;
|
||||
pub use eyreish::*;
|
||||
#[cfg(feature = "fancy-no-backtrace")]
|
||||
pub use handler::*;
|
||||
pub use handlers::*;
|
||||
pub use miette_diagnostic::*;
|
||||
pub use named_source::*;
|
||||
#[cfg(feature = "fancy")]
|
||||
pub use panic::*;
|
||||
|
|
@ -632,7 +632,6 @@ pub use protocol::*;
|
|||
|
||||
mod chain;
|
||||
mod diagnostic_chain;
|
||||
mod dynamic_diagnostic;
|
||||
mod error;
|
||||
mod eyreish;
|
||||
#[cfg(feature = "fancy-no-backtrace")]
|
||||
|
|
@ -640,6 +639,7 @@ mod handler;
|
|||
mod handlers;
|
||||
#[doc(hidden)]
|
||||
pub mod macro_helpers;
|
||||
mod miette_diagnostic;
|
||||
mod named_source;
|
||||
#[cfg(feature = "fancy")]
|
||||
mod panic;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::Diagnostic;
|
|||
|
||||
/// Diagnostic that can be created at runtime.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct DynamicDiagnostic {
|
||||
pub struct MietteDiagnostic {
|
||||
/// Displayed diagnostic description
|
||||
pub description: String,
|
||||
/// Unique diagnostic code to look up more information
|
||||
|
|
@ -18,15 +18,15 @@ pub struct DynamicDiagnostic {
|
|||
pub code: Option<String>,
|
||||
}
|
||||
|
||||
impl Display for DynamicDiagnostic {
|
||||
impl Display for MietteDiagnostic {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
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>> {
|
||||
self.code
|
||||
.as_ref()
|
||||
|
|
@ -35,14 +35,14 @@ impl Diagnostic for DynamicDiagnostic {
|
|||
}
|
||||
}
|
||||
|
||||
impl DynamicDiagnostic {
|
||||
impl MietteDiagnostic {
|
||||
/// Create a new dynamic diagnostic with the given description.
|
||||
///
|
||||
/// # 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.description, "Oops, something went wrong!");
|
||||
/// ```
|
||||
|
|
@ -57,9 +57,9 @@ impl DynamicDiagnostic {
|
|||
///
|
||||
/// # 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.code, Some("foo::bar::baz".to_string()));
|
||||
/// ```
|
||||
Loading…
Reference in New Issue