sublime_color_scheme/
error.rs

1use syntect::{highlighting::ParseThemeError, parsing::ParseScopeError};
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum ParseError {
6    // File and JSON Parsing Errors
7    #[error("Failed to open file")]
8    OpenFile(#[from] std::io::Error),
9    #[error("Failed to parse JSON")]
10    Json(#[from] serde_json::Error),
11    #[error("Failed to parse JSONC")]
12    Jsonc(#[from] jsonc_parser::errors::ParseError),
13
14    // Color Parsing Errors
15    #[error("Failed to parse hex color")]
16    InvalidHexColor,
17    #[error("Failed to convert keyword to color")]
18    InvalidKeyword,
19    #[error("Not a valid color function")]
20    InvalidColorFunction,
21    #[error("Failed to parse color space")]
22    ParseColorSpace,
23
24    // Function and Expression Parsing Errors
25    #[error("Failed to parse variable function")]
26    InvalidVariable,
27    #[error("Failed to parse adjuster")]
28    ParseAdjuster,
29    #[error("Failed to parse function")]
30    ParseFunction,
31    #[error("Failed to parse expression")]
32    ParseExpression,
33    #[error("Could not find variable")]
34    UnknownVariable,
35
36    // Number Parsing Errors
37    #[error("Failed to parse number string: {0}")]
38    InvalidNumber(String),
39    #[error("Failed to parse float number")]
40    ParseNumber(#[from] std::num::ParseFloatError),
41    #[error("Failed to parse integer number")]
42    ParseInteger(#[from] std::num::ParseIntError),
43
44    // Scope and Theme Parsing Errors
45    #[error("Failed to parse scope")]
46    ParseScope(#[from] ParseScopeError),
47    #[error("Failed to parse theme")]
48    ParseTheme(#[from] ParseThemeError),
49}