Skip to main content

decant_render/
error.rs

1//! Error types for `decant-render`.
2
3use thiserror::Error;
4
5/// Errors that can arise from the headless-Chrome renderer.
6#[derive(Debug, Error)]
7pub enum RenderError {
8    /// The crate was compiled without the `render` feature.
9    #[error(
10        "`decant` was built without the `render` feature. \
11         Reinstall with: cargo install decant --features render"
12    )]
13    FeatureNotEnabled,
14
15    /// chromiumoxide / browser launch failed.
16    #[cfg(feature = "render")]
17    #[error("browser launch failed: {0}")]
18    BrowserLaunch(String),
19
20    /// Lightpanda binary not found in PATH or environment.
21    #[cfg(feature = "render")]
22    #[error("lightpanda binary not found: {0}")]
23    LightpandaNotFound(String),
24
25    /// Chrome binary not found in PATH or environment.
26    #[cfg(feature = "render")]
27    #[error("chrome binary not found: {0}")]
28    ChromeNotFound(String),
29
30    /// CDP connection failed.
31    #[cfg(feature = "render")]
32    #[error("CDP connection failed: {0}")]
33    CdpConnection(String),
34
35    /// Page navigation or evaluation failed.
36    #[cfg(feature = "render")]
37    #[error("page error for `{url}`: {message}")]
38    Page {
39        /// The URL that triggered the page error.
40        url: String,
41        /// The error message.
42        message: String,
43    },
44
45    /// Screenshot capture failed.
46    #[cfg(feature = "render")]
47    #[error("screenshot failed for `{url}`: {message}")]
48    Screenshot {
49        /// The URL that triggered the screenshot error.
50        url: String,
51        /// The error message.
52        message: String,
53    },
54}