1#[derive(Debug, PartialEq)]
3pub enum Error {
4 NonZeroDeterminantMatrix,
7 SingularMatrixNotInversible,
10}
11
12impl std::fmt::Display for Error {
13 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14 match self {
15 Error::NonZeroDeterminantMatrix => {
16 write!(f, "Matrix determinant should be different from ZERO")
17 }
18 Error::SingularMatrixNotInversible => {
19 write!(f, "Matrix3x3 cannont be inverse because it is singular")
20 }
21 }
22 }
23}
24
25impl std::error::Error for Error {
26 fn description(&self) -> &str {
27 match self {
28 Error::NonZeroDeterminantMatrix => "Matrix determinant should be different from ZERO",
29 Error::SingularMatrixNotInversible => {
30 "Matrix3x3 cannont be inverse because it is singular"
31 }
32 }
33 }
34
35 fn cause(&self) -> Option<&dyn std::error::Error> {
36 Some(self)
37 }
38}