use crate::var::Var;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("node is not present in this `Context`")]
BadNode,
#[error("variable is not present in this `Context`")]
BadVar,
#[error("variable {0} is missing in the evaluation map")]
MissingVar(Var),
#[error("node does not have an associated variable")]
NotAVar,
#[error("node is not a constant")]
NotAConst,
#[error("`Context` is empty")]
EmptyContext,
#[error("`IndexMap` is empty")]
EmptyMap,
#[error("unknown opcode {0}")]
UnknownOpcode(String),
#[error("unknown variable {0}")]
UnknownVariable(String),
#[error("empty file")]
EmptyFile,
#[error("choice slice length ({0}) does not match choice count ({1})")]
BadChoiceSlice(usize, usize),
#[error("variable slice lengths are mismatched")]
MismatchedSlices,
#[error("variable slice length ({0}) does not match expected count ({1})")]
BadVarSlice(usize, usize),
#[error("variable index ({0}) exceeds max var index for this tape ({1})")]
BadVarIndex(usize, usize),
#[error("could not solve for matrix pseudo-inverse: {0}")]
SingularMatrix(&'static str),
#[error("io error: {0}")]
IoError(#[from] std::io::Error),
#[error("bad tile sizes; {0} is not divisible by {1}")]
BadTileSize(usize, usize),
#[error("bad tile order; {0} is not larger than {1}")]
BadTileOrder(usize, usize),
#[error("tile size list must not be empty")]
EmptyTileSizes,
}