Skip to content

Commit 8ec64f5

Browse files
committed
Add StrideError
1 parent fb2bfe7 commit 8ec64f5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/error.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,34 @@ impl error::Error for NotSquareError {
4444
}
4545
}
4646

47+
#[derive(Debug)]
48+
pub struct StrideError {}
49+
50+
impl fmt::Display for StrideError {
51+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52+
write!(f, "invalid stride")
53+
}
54+
}
55+
56+
impl error::Error for StrideError {
57+
fn description(&self) -> &str {
58+
"invalid stride"
59+
}
60+
}
61+
4762
#[derive(Debug)]
4863
pub enum LinalgError {
4964
NotSquare(NotSquareError),
5065
Lapack(LapackError),
66+
Stride(StrideError),
5167
}
5268

5369
impl fmt::Display for LinalgError {
5470
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5571
match *self {
5672
LinalgError::NotSquare(ref err) => err.fmt(f),
5773
LinalgError::Lapack(ref err) => err.fmt(f),
74+
LinalgError::Stride(ref err) => err.fmt(f),
5875
}
5976
}
6077
}
@@ -64,6 +81,7 @@ impl error::Error for LinalgError {
6481
match *self {
6582
LinalgError::NotSquare(ref err) => err.description(),
6683
LinalgError::Lapack(ref err) => err.description(),
84+
LinalgError::Stride(ref err) => err.description(),
6785
}
6886
}
6987
}
@@ -79,3 +97,9 @@ impl From<LapackError> for LinalgError {
7997
LinalgError::Lapack(err)
8098
}
8199
}
100+
101+
impl From<StrideError> for LinalgError {
102+
fn from(err: StrideError) -> LinalgError {
103+
LinalgError::Stride(err)
104+
}
105+
}

0 commit comments

Comments
 (0)