safety_net/
error.rs

1/*!
2
3  Error types.
4
5*/
6
7use thiserror::Error;
8
9use crate::circuit::{Identifier, Net};
10
11/// Errors for the `safety-net` library.
12#[derive(Error, Debug)]
13pub enum Error {
14    /// Error for an analysis cannot run due to  cycles.
15    #[error("Cycles detected along nets {0:?}")]
16    CycleDetected(Vec<Net>),
17    /// Errors in parsing literals/identifiers.
18    #[error("Parsing error `{0}`")]
19    ParseError(String),
20    /// The labeled nets in the netlist are not unique.
21    #[error("Non-unique nets: {0:?}")]
22    NonuniqueNets(Vec<Net>),
23    /// The labeled instances in the netlist are not unique.
24    #[error("Non-unique instances: {0:?}")]
25    NonuniqueInsts(Vec<Identifier>),
26    /// The netlist has no outputs.
27    #[error("No outputs in netlist")]
28    NoOutputs,
29    /// An error in the instantiable interface
30    #[error("Error in the instantiable interface: {0}")]
31    InstantiableError(String),
32    /// A deletion would cause a dangling reference.
33    #[error("Attempted to create a dangling reference to nets {0:?}")]
34    DanglingReference(Vec<Net>),
35    /// Mismatch in number of arguments
36    #[error("Expected {0} arguments, got {1}")]
37    ArgumentMismatch(usize, usize),
38    /// An input needs an alias to be an output
39    #[error("Input net {0} needs an alias to be an output")]
40    InputNeedsAlias(Net),
41    /// A net that was expected but not found
42    #[error("Expected to find net {0} in netlist")]
43    NetNotFound(Net),
44}