use thiserror::Error;
#[derive(Debug, Error)]
pub enum WebUIError {
#[error("I/O error: {context}")]
Io {
context: String,
#[source]
source: std::io::Error,
},
#[error("Component registration error: {0}")]
ComponentRegistration(String),
#[error("Component discovery error: {0}")]
ComponentDiscovery(String),
#[error("{context}")]
Parse {
context: String,
#[source]
source: webui_parser::ParserError,
},
#[error("protocol error")]
Protocol(#[from] webui_protocol::ProtocolError),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("rendering error")]
Rendering(#[from] webui_handler::HandlerError),
#[error("Invalid build options: {0}")]
InvalidBuildOptions(String),
#[error("{0}")]
ComponentAssets(Box<webui_parser::Diagnostic>),
#[error("{0}")]
Projection(Box<webui_parser::Diagnostic>),
}
impl WebUIError {
#[must_use]
pub fn chain_message(&self) -> String {
let mut message = self.to_string();
let mut source = std::error::Error::source(self);
while let Some(err) = source {
message.push_str(": ");
message.push_str(&err.to_string());
source = err.source();
}
message
}
}