vscode_theme_syntect/
error.rs

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