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
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::convert::Infallible;

use thiserror::Error;
use tree_sitter::QueryError;

use crate::style::ParseHexError;

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

#[derive(Debug, Error)]
pub enum Error {
    #[error("link to unknown key '{0}'")]
    InvalidLink(String),

    #[error("unsuppoerted language with name '{0}'")]
    UnsupportedLanguage(String),

    #[error("unsuppoerted file extension '{0}'")]
    UnsupportedFileExt(String),

    #[error("missing queries for language '{0}'")]
    MissingQueries(String),

    #[error(transparent)]
    InvalidHex(#[from] ParseHexError),

    #[error(transparent)]
    MalformedQueries(#[from] QueryError),

    #[error(transparent)]
    Highlight(#[from] syntastica_highlight::Error),
}

impl From<Infallible> for Error {
    fn from(_: Infallible) -> Self {
        unreachable!("`Infallible` cannot be constructed")
    }
}