voml_types/error/
mod.rs

1use std::{
2    convert::Infallible,
3    error::Error,
4    fmt::{Debug, Display, Formatter},
5};
6
7use crate::DuplicateItem;
8use diagnostic::{DiagnosticLevel, FileID, Span};
9
10mod for_std;
11
12pub mod duplicate;
13
14/// All result about notedown
15pub type VResult<T = ()> = Result<T, VError>;
16
17/// Many errors
18pub type Validation<T> = diagnostic::Validation<T, VError>;
19
20/// Error type for all Notedown operators
21#[derive(Debug)]
22pub struct VError {
23    /// Actual error kind
24    pub kind: Box<VErrorKind>,
25    /// Error level for report
26    pub level: DiagnosticLevel,
27    /// File name where error occurred
28    pub file: FileID,
29}
30
31/// Actual error data for the error
32pub enum VErrorKind {
33    /// The error type for I/O operations
34    IOError(std::io::Error),
35    /// The error type for I/O operations
36    ParseError(ParseFail),
37    /// The error type for I/O operations
38    Duplicate(DuplicateItem),
39    /// Unknown error
40    Custom(String),
41}
42
43#[derive(Debug)]
44pub struct ParseFail {
45    pub message: String,
46    pub span: Span,
47}