valkyrie-errors 0.0.3

Error types for valkyrie language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use toml::de::Error;

use crate::{FileSpan, SyntaxError, ValkyrieError};

impl From<Error> for SyntaxError {
    fn from(value: Error) -> Self {
        match value.span() {
            Some(s) => Self { info: value.message().to_string(), span: FileSpan { file: 0, head: s.start, tail: s.end } },
            None => Self { info: value.message().to_string(), span: Default::default() },
        }
    }
}

impl From<Error> for ValkyrieError {
    fn from(value: Error) -> Self {
        SyntaxError::from(value).into()
    }
}