Skip to main content

logicaffeine_compile/extraction/
error.rs

1//! Error types for program extraction.
2
3use std::fmt;
4
5/// Errors that can occur during extraction.
6#[derive(Debug)]
7pub enum ExtractError {
8    /// Name not found in context.
9    NotFound(String),
10
11    /// Cannot extract this kind of term (e.g., Prop).
12    NotExtractable { name: String, reason: String },
13
14    /// Internal extraction error.
15    Internal(String),
16}
17
18impl fmt::Display for ExtractError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            ExtractError::NotFound(name) => write!(f, "Not found: {}", name),
22            ExtractError::NotExtractable { name, reason } => {
23                write!(f, "Cannot extract '{}': {}", name, reason)
24            }
25            ExtractError::Internal(msg) => write!(f, "Internal error: {}", msg),
26        }
27    }
28}
29
30impl std::error::Error for ExtractError {}