#![warn(missing_docs)]
use std::fmt::{Display, Formatter, Result};
#[derive(Debug, PartialEq)]
pub enum MatrixError {
MatrixCreationError,
MatrixIndexOutOfBoundsError,
MatrixMultiplicationDimensionMismatchError,
MatrixDimensionMismatchError,
MatrixConcatinationError,
MatrixParseError,
MatrixDivideByZeroError,
MatrixFileReadError(&'static str),
}
impl Display for MatrixError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
MatrixError::MatrixCreationError => {
write!(f, "There was an error creating the matrix.")
}
MatrixError::MatrixIndexOutOfBoundsError => {
write!(f, "The indexes are out of bounds for the matrix")
}
MatrixError::MatrixMultiplicationDimensionMismatchError => {
write!(
f,
"The two matrices supplied are not on the form M x N @ N x P"
)
}
MatrixError::MatrixDimensionMismatchError => {
write!(f, "The matrixs provided are both not on the form M x N")
}
MatrixError::MatrixConcatinationError => {
write!(
f,
"Matrixs could not be concatinated or extended due to more than 1 dim mismatch"
)
}
MatrixError::MatrixParseError => write!(f, "Failed to parse matrix from file"),
MatrixError::MatrixDivideByZeroError => write!(f, "Tried to divide by zero"),
MatrixError::MatrixFileReadError(path) => {
write!(f, "Could not read file from path: {}", path)
}
}
}
}