1use std::fmt;
2use std::fmt::Display;
3
4#[derive(Debug, Clone)]
5pub struct NmlError {
6 error_type: ErrorKind,
7}
8
9impl NmlError {
10 pub fn new(error_type: ErrorKind) -> Self {
11 Self {
12 error_type,
13 }
14 }
15}
16
17impl Display for NmlError {
18 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19 write!(f, "{:?}", self.error_type)
20 }
21}
22
23#[derive(Debug, Clone)]
24pub enum ErrorKind {
25 InvalidRows,
26 InvalidCols,
27 CreateMatrix,
28 MatrixNotSquare
29}
30
31impl Display for ErrorKind {
32 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
33 match self {
34 ErrorKind::InvalidCols => write!(f, "Invalid number of columns"),
35 ErrorKind::InvalidRows => write!(f, "Invalid number of rows"),
36 ErrorKind::CreateMatrix => write!(f, "Unable to create matrix"),
37 ErrorKind::MatrixNotSquare => write!(f, "Matrix is not square"),
38 }
39 }
40}