Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Jul 28, 2018
1 parent 066897e commit 96cb439
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ impl<T, E: IntoPyErr> IntoPyResult for Result<T, E> {
/// Error for casting `PyArray` into `ArrayView` or `ArrayViewMut`
#[derive(Debug)]
pub enum ArrayCastError {
ToRust {
test: i32,
truth: i32,
},
ToRust { test: i32, truth: i32 },
FromVec,
}

Expand All @@ -39,20 +36,18 @@ impl ArrayCastError {
impl fmt::Display for ArrayCastError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ArrayCastError::ToRust { test, truth } => {
ArrayCastError::ToRust { test, truth } => {
write!(f, "Cast failed: from={}, to={}", test, truth)
}
ArrayCastError::FromVec => {
write!(f, "Cast failed: FromVec (maybe invalid dimension)")
}
ArrayCastError::FromVec => write!(f, "Cast failed: FromVec (maybe invalid dimension)"),
}
}
}

impl error::Error for ArrayCastError {
fn description(&self) -> &str {
match self {
ArrayCastError::ToRust {..} => "ArrayCast failed(IntoArray)",
ArrayCastError::ToRust { .. } => "ArrayCast failed(IntoArray)",
ArrayCastError::FromVec => "ArrayCast failed(FromVec)",
}
}
Expand All @@ -61,7 +56,7 @@ impl error::Error for ArrayCastError {
impl IntoPyErr for ArrayCastError {
fn into_pyerr(self, msg: &str) -> PyErr {
let msg = match self {
ArrayCastError::ToRust {..} => {
ArrayCastError::ToRust { .. } => {
format!("rust_numpy::ArrayCastError::IntoArray: {}", msg)
}
ArrayCastError::FromVec => format!("rust_numpy::ArrayCastError::FromVec: {}", msg),
Expand Down

0 comments on commit 96cb439

Please sign in to comment.