vos_error/errors/
mod.rs

1use std::{
2    error::Error,
3    fmt::{Display, Formatter},
4};
5
6use diagnostic::{DiagnosticLevel, FileID};
7
8use crate::{DuplicateDeclare, VosError, VosErrorKind};
9
10pub mod report;
11
12impl Display for VosError {
13    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14        write!(f, "{:#?}", self)
15    }
16}
17
18impl Error for VosError {}
19
20impl VosError {
21    pub fn kind(&self) -> &VosErrorKind {
22        &*self.kind
23    }
24}
25
26impl DuplicateDeclare {
27    pub fn build(self, file: FileID) -> VosError {
28        VosError { kind: Box::new(VosErrorKind::DuplicateFields(self)), level: DiagnosticLevel::Warning, file }
29    }
30}