webui/error.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT license.
3
4//! Error types for the WebUI library.
5
6use thiserror::Error;
7
8/// Errors that can occur during WebUI build, render, or inspection operations.
9#[derive(Debug, Error)]
10pub enum WebUIError {
11 /// I/O error (file read/write failures).
12 #[error("I/O error: {context}: {source}")]
13 Io {
14 /// What operation failed.
15 context: String,
16 /// The underlying I/O error.
17 #[source]
18 source: std::io::Error,
19 },
20
21 /// Component registration failure.
22 #[error("Component registration error: {0}")]
23 ComponentRegistration(String),
24
25 /// Component discovery failure (npm packages or local paths).
26 #[error("Component discovery error: {0}")]
27 ComponentDiscovery(String),
28
29 /// HTML/CSS parsing failure with context about which file failed.
30 #[error("{context}: {source}")]
31 Parse {
32 /// What was being parsed.
33 context: String,
34 /// The underlying parse error.
35 #[source]
36 source: webui_parser::ParserError,
37 },
38
39 /// Protocol serialization or deserialization failure.
40 #[error("{0}")]
41 Protocol(#[from] webui_protocol::ProtocolError),
42
43 /// JSON serialization failure.
44 #[error("Serialization error: {0}")]
45 Serialization(String),
46
47 /// Handler rendering error.
48 #[error("{0}")]
49 Rendering(#[from] webui_handler::HandlerError),
50}