-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathlib.rs
38 lines (34 loc) · 914 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod diagnostic;
mod formatter;
mod label;
mod note;
mod severity;
mod span;
pub use diagnostic::{Diagnostic, DiagnosticList};
pub use formatter::Formatter;
pub use label::Label;
pub use note::Note;
pub use severity::Severity;
pub use span::{span, Span};
/// A trait that can be implemented by error types to provide diagnostic
/// information about the given error.
pub trait DiagnosticError: std::error::Error {
/// The subject message of the error.
///
/// Defaults to the error message itself.
fn message(&self) -> String {
self.to_string()
}
/// One or more labels to provide more context for a given error.
///
/// Defaults to no labels.
fn labels(&self) -> Vec<Label> {
vec![]
}
/// One or more notes shown at the bottom of the diagnostic message.
///
/// Defaults to no notes.
fn notes(&self) -> Vec<Note> {
vec![]
}
}