factorize internal error macro

This commit is contained in:
marin postma 2021-06-15 17:55:27 +02:00
parent 02277ec2cf
commit 0d3fb5ee0d
No known key found for this signature in database
GPG key ID: 6088B7721C3E39F9
11 changed files with 62 additions and 84 deletions

View file

@ -15,19 +15,13 @@ pub enum IndexError {
Facet(#[from] FacetError),
}
macro_rules! internal_error {
($($other:path), *) => {
$(
impl From<$other> for IndexError {
fn from(other: $other) -> Self {
Self::Internal(Box::new(other))
}
}
)*
}
}
internal_error!(std::io::Error, heed::Error, fst::Error, serde_json::Error);
internal_error!(
IndexError:
std::io::Error,
heed::Error,
fst::Error,
serde_json::Error
);
impl ErrorCode for IndexError {
fn error_code(&self) -> Code {