fidget_core/
error.rs

1//! Module containing the Fidget universal error type
2use crate::var::Var;
3use thiserror::Error;
4
5/// Universal error type for Fidget
6#[derive(Error, Debug)]
7pub enum Error {
8    /// Node is not present in this `Context`
9    #[error("node is not present in this `Context`")]
10    BadNode,
11
12    /// Variable is not present in this `Context`
13    #[error("variable is not present in this `Context`")]
14    BadVar,
15
16    /// Variable is missing in the evaluation map
17    #[error("variable {0} is missing in the evaluation map")]
18    MissingVar(Var),
19
20    /// The given node does not have an associated variable
21    #[error("node does not have an associated variable")]
22    NotAVar,
23
24    /// The given node is not a constant
25    #[error("node is not a constant")]
26    NotAConst,
27
28    /// `Context` is empty
29    #[error("`Context` is empty")]
30    EmptyContext,
31
32    /// `IndexMap` is empty
33    #[error("`IndexMap` is empty")]
34    EmptyMap,
35
36    /// Unknown opcode {0}
37    #[error("unknown opcode {0}")]
38    UnknownOpcode(String),
39
40    /// Unknown variable {0}
41    #[error("unknown variable {0}")]
42    UnknownVariable(String),
43
44    /// Empty file
45    #[error("empty file")]
46    EmptyFile,
47
48    /// Choice slice length does not match choice count
49    #[error("choice slice length ({0}) does not match choice count ({1})")]
50    BadChoiceSlice(usize, usize),
51
52    /// Variable slice lengths are mismatched
53    #[error("variable slice lengths are mismatched")]
54    MismatchedSlices,
55
56    /// Variable slice length does not match expected count
57    #[error("variable slice length ({0}) does not match expected count ({1})")]
58    BadVarSlice(usize, usize),
59
60    /// Variable index exceeds max var index for this tape
61    #[error("variable index ({0}) exceeds max var index for this tape ({1})")]
62    BadVarIndex(usize, usize),
63
64    /// Could not solve for matrix pseudo-inverse
65    #[error("could not solve for matrix pseudo-inverse: {0}")]
66    SingularMatrix(&'static str),
67
68    /// IO error; see inner code for details
69    #[error("io error: {0}")]
70    IoError(#[from] std::io::Error),
71
72    /// Each tile must be divisible by subsequent tiles
73    #[error("bad tile sizes; {0} is not divisible by {1}")]
74    BadTileSize(usize, usize),
75
76    /// Tile size list must be in descending order
77    #[error("bad tile order; {0} is not larger than {1}")]
78    BadTileOrder(usize, usize),
79
80    /// Tile size list must not be empty
81    #[error("tile size list must not be empty")]
82    EmptyTileSizes,
83}