anticipate_core/
error.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4/// Error lexing a source file.
5#[derive(Debug, Error, PartialEq, Clone, Default)]
6#[doc(hidden)]
7pub enum LexError {
8    /// Generic lex error.
9    #[default]
10    #[error("parser lex error")]
11    Other,
12}
13
14/// Errors generated by the library.
15#[derive(Debug, Error)]
16pub enum Error {
17    /// Bad arguments.
18    #[error("Bad command arguments: '{0}'")]
19    BadArguments(String),
20
21    /// Include file not found.
22    #[error("include file '{0}' not found ({1})")]
23    Include(String, PathBuf),
24
25    /// Unknown instruction.
26    #[error("unknown instruction '{0}'")]
27    UnknownInstruction(String),
28
29    /// Invalid control code.
30    #[error("invalid control code '{0}'")]
31    InvalidControlCode(String),
32
33    /// Script pragma must be first instruction.
34    #[error("pragma declaration ($!) must be the first instruction")]
35    PragmaFirst,
36
37    /// Error generated by the io module.
38    #[error(transparent)]
39    Io(#[from] std::io::Error),
40
41    /// Error generated parsing to an integer.
42    #[error(transparent)]
43    ParseInt(#[from] std::num::ParseIntError),
44
45    /// Error generated by the pseudo-terminal library.
46    #[error(transparent)]
47    Expect(#[from] anticipate::Error),
48
49    /// Error during lexing.
50    #[error(transparent)]
51    Lex(#[from] LexError),
52}