use std::fmt;
#[derive(Debug)]
pub enum NativeError {
WindowCreation(String),
GpuInit(String),
DiffEmpty,
WindowDestroyed(winit::window::WindowId),
EventLoop(String),
}
impl fmt::Display for NativeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NativeError::WindowCreation(msg) => write!(
f,
"Window creation failed: {msg}. Check display server connection."
),
NativeError::GpuInit(msg) => write!(
f,
"GPU initialization failed: {msg}. Verify drivers and GPU availability."
),
NativeError::DiffEmpty => write!(
f,
"VDom diff produced no patches but rebuild was expected. This is a bug."
),
NativeError::WindowDestroyed(id) => write!(
f,
"Window {id:?} was destroyed but events are still being dispatched."
),
NativeError::EventLoop(msg) => write!(f, "Event loop error: {msg}"),
}
}
}
impl std::error::Error for NativeError {}