Skip to main content

webui_parser/
error.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT license.
3
4//! Error handling for the WebUI parser.
5
6use thiserror::Error;
7
8/// Result type for WebUI parser operations.
9pub type Result<T> = std::result::Result<T, ParserError>;
10
11/// Error type for WebUI parser.
12#[derive(Debug, Error)]
13pub enum ParserError {
14    /// Generic error.
15    #[error("Generic error: {0}")]
16    Generic(String),
17
18    /// I/O error with context.
19    #[error("I/O error: {context}: {source}")]
20    IO {
21        /// What operation failed.
22        context: String,
23        /// The underlying I/O error.
24        #[source]
25        source: std::io::Error,
26    },
27
28    /// Parse error.
29    #[error("Parse error: {0}")]
30    Parse(String),
31
32    /// Component error.
33    #[error("Component error: {0}")]
34    Component(String),
35
36    /// CSS error.
37    #[error("CSS error: {0}")]
38    Css(String),
39
40    /// HTML error.
41    #[error("HTML error: {0}")]
42    Html(String),
43
44    /// Directive error.
45    #[error("Directive error: {0}")]
46    Directive(String),
47
48    /// Entity not found error.
49    #[error("Not found: {0}")]
50    NotFound(String),
51
52    /// TypeScript parse error.
53    #[error("TypeScript parse error: {0}")]
54    TsParseError(String),
55}