Skip to main content

textfsm_core/clitable/
error.rs

1//! Error types for CliTable operations.
2
3use std::collections::HashMap;
4use std::path::PathBuf;
5
6use thiserror::Error;
7
8use crate::error::{ParseError, TemplateError};
9
10/// Errors that occur during CliTable operations.
11#[derive(Error, Debug)]
12pub enum CliTableError {
13    /// Error parsing the index file.
14    #[error("index parse error at line {line}: {message}")]
15    IndexParse { line: usize, message: String },
16
17    /// No template matched the provided attributes.
18    #[error("no matching template found for attributes: {0:?}")]
19    NoMatch(HashMap<String, String>),
20
21    /// Template file referenced in index was not found.
22    #[error("template file not found: {0}")]
23    TemplateNotFound(PathBuf),
24
25    /// Invalid completion syntax in index file.
26    #[error("invalid completion syntax: {0}")]
27    InvalidCompletion(String),
28
29    /// Invalid regex pattern in index file.
30    #[error("invalid regex pattern at line {line}: {message}")]
31    InvalidRegex { line: usize, message: String },
32
33    /// Missing required column in index file.
34    #[error("missing required column '{0}' in index file")]
35    MissingColumn(String),
36
37    /// Template parsing error.
38    #[error(transparent)]
39    Template(#[from] TemplateError),
40
41    /// Text parsing error.
42    #[error(transparent)]
43    Parse(#[from] ParseError),
44
45    /// I/O error.
46    #[error("I/O error: {0}")]
47    Io(#[from] std::io::Error),
48}