1 use std::io; 2 3 use thiserror::Error; 4 5 use crate::{self as miette, Diagnostic}; 6 7 /** 8 Error enum for miette. Used by certain operations in the protocol. 9 */ 10 #[derive(Debug, Diagnostic, Error)] 11 pub enum MietteError { 12 /// Wrapper around [`std::io::Error`]. This is returned when something went 13 /// wrong while reading a [`SourceCode`](crate::SourceCode). 14 #[error(transparent)] 15 #[diagnostic(code(miette::io_error), url(docsrs))] 16 IoError(#[from] io::Error), 17 18 /// Returned when a [`SourceSpan`](crate::SourceSpan) extends beyond the 19 /// bounds of a given [`SourceCode`](crate::SourceCode). 20 #[error("The given offset is outside the bounds of its Source")] 21 #[diagnostic( 22 code(miette::span_out_of_bounds), 23 help("Double-check your spans. Do you have an off-by-one error?"), 24 url(docsrs) 25 )] 26 OutOfBounds, 27 } 28