reverted to single ReadNAtom error type

This commit is contained in:
daniel
2020-11-12 09:59:59 +01:00
parent 90c4c73887
commit 80b6cafc66
3 changed files with 8 additions and 13 deletions

View File

@@ -26,8 +26,7 @@ pub enum Error {
InvalidOsStr,
/// A path could not be converted to &CStr because it had a null byte
NullInStr(std::ffi::NulError),
CheckNAtomsDuringRead(Box<Error>),
CheckNAtomsDuringIter(Box<Error>),
CouldNotCheckNAtoms(Box<Error>),
}
impl Error {
@@ -64,7 +63,7 @@ impl std::error::Error for Error {
use Error::*;
match &self {
NullInStr(err) => Some(err),
CheckNAtomsDuringRead(err) | CheckNAtomsDuringIter(err) => Some(err.as_ref()),
CouldNotCheckNAtoms(err) => Some(err.as_ref()),
_ => None,
}
}
@@ -123,14 +122,10 @@ impl std::fmt::Display for Error {
}
InvalidOsStr => write!(f, "Paths must be valid unicode on this platform"),
NullInStr(_err) => write!(f, "Paths cannot include null bytes"),
CheckNAtomsDuringRead(_err) => write!(
CouldNotCheckNAtoms(_err) => write!(
f,
"Failed to check number of atoms in trajectory while reading a frame"
),
CheckNAtomsDuringIter(_err) => write!(
f,
"Failed to check number of atoms in trajectory while creating iterator"
),
"Failed to read number of atoms in trajectory file"
)
}
}
}