Skip to main content

cooklang_import/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during recipe import operations
4#[derive(Error, Debug)]
5pub enum ImportError {
6    /// Failed to fetch recipe from URL
7    #[error("Failed to fetch URL: {0}")]
8    FetchError(#[from] reqwest::Error),
9
10    /// Failed to parse recipe from webpage
11    #[error("Failed to parse recipe: {0}")]
12    ParseError(String),
13
14    /// No extractor could successfully parse the recipe
15    #[error("No extractor could parse the recipe from this webpage")]
16    NoExtractorMatched,
17
18    /// Failed to convert recipe to Cooklang format
19    #[error("Conversion failed: {0}")]
20    ConversionError(String),
21
22    /// Invalid markdown format provided
23    #[error("Invalid markdown format: {0}")]
24    InvalidMarkdown(String),
25
26    /// Builder configuration error
27    #[error("Builder error: {0}")]
28    BuilderError(String),
29
30    /// Extraction error (from URL, image, or text)
31    #[error("Extraction failed: {0}")]
32    ExtractionError(String),
33
34    /// Error parsing HTTP headers
35    #[error("Header parse error: {0}")]
36    HeaderError(#[from] reqwest::header::InvalidHeaderValue),
37
38    /// Environment variable error
39    #[error("Environment variable error: {0}")]
40    EnvError(#[from] std::env::VarError),
41
42    /// Configuration error
43    #[error("Configuration error: {0}")]
44    ConfigError(#[from] config::ConfigError),
45}