1use std::{
2 convert::Infallible,
3 error::Error,
4 fmt::{Debug, Display, Formatter},
5};
6
7use diagnostic::{DiagnosticLevel, FileID, Span};
8
9mod for_std;
10
11pub type Result<T = ()> = std::result::Result<T, VomlError>;
13
14pub type Validation<T> = diagnostic::Validation<T, VomlError>;
16
17#[derive(Debug)]
19pub struct VomlError {
20 pub kind: Box<VomlErrorKind>,
22 pub level: DiagnosticLevel,
24 pub file: FileID,
26}
27
28#[derive(Debug)]
30pub enum VomlErrorKind {
31 IOError(std::io::Error),
33 ParseError(ParseFail),
35 UnknownError,
37}
38
39#[derive(Debug)]
40pub struct ParseFail {
41 pub message: String,
42 pub span: Span,
43}
44
45impl Error for VomlError {}
46
47impl Display for VomlError {
48 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
49 Debug::fmt(self, f)
50 }
51}
52
53impl Display for VomlErrorKind {
54 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
55 Debug::fmt(self, f)
56 }
57}