1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::{Range, Span};
use indexmap::IndexMap;

pub type Result<T> = std::result::Result<T, Error>;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error(transparent)]
    Io(#[from] std::io::Error),

    #[error("Really pretty much anything")]
    Any,

    #[error("Failed to parse toml file")]
    Toml(#[from] toml::de::Error),

    #[error("{0}")]
    Span(String),

    #[error("BUG: Found a range {}..{} which that does not exist in its own source mapping: {:?}", .line_range.start, .line_range.end, .source_mapping)]
    InvalidLineRange {
        line_range: Range,
        source_mapping: IndexMap<Range, Span>,
    },
}