Error Types
Renderer Errors
pub enum ScreenshotError {
SurfaceError(wgpu::SurfaceError),
BufferMapError,
ImageEncodingError,
}
pub enum NodeScreenshotError {
NoLayout,
NodeNotFound(Vec<usize>),
EmptyRect,
Render(ScreenshotError),
}
Frame Outcome
pub enum FrameOutcome {
Presented, // Frame rendered successfully
Reconfigure, // Surface lost, must call resize() and retry
Skipped, // Nothing to draw (empty display list)
}
Pipeline Errors
The pipeline functions use Option returns rather than Result for expected states:
compute_layout()returnsNonewhen the tree is emptypaint_tree_returning_layout()returnsOption<LayoutBox>—Noneif no contentscreenshot_node_to()returnsNodeScreenshotErrorfor missing or empty nodes
Parser Behavior
The HTML parser is lenient. Invalid HTML is recovered gracefully:
- Unknown tags drop their entire subtree silently
- Mismatched tags follow auto-close rules
- Invalid CSS properties are silently ignored (not parsed)
- CSS parse errors don't prevent the rest of the stylesheet from working
Layout Behavior
display: nonechildren are excluded from layout (no error)- Unsupported CSS values fall back to defaults (e.g., unknown
displayvalue →block) - Missing fonts fall back to the first registered font
- Images that fail to load are silently hidden
- Gradients with invalid parameters degrade to a solid 1×1 transparent pixel
Error Handling Pattern
For custom integrations, wrap the pipeline:
match lui::compute_layout(&tree, &mut text_ctx, &mut image_cache, vw, vh, scale) {
Some(layout) => { /* render */ }
None => { /* tree is empty, show placeholder */ }
}