Skip to content

Commit

Permalink
add ZipError to handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Dec 14, 2024
1 parent 464de27 commit 3f4bcae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ pub enum SourmashError {
#[cfg(feature = "branchwater")]
#[error(transparent)]
RocksDBError(#[from] rocksdb::Error),

#[error(transparent)]
ZipError(#[from] piz::result::ZipError),
}

#[derive(Debug, Error)]
Expand Down Expand Up @@ -140,6 +143,7 @@ pub enum SourmashErrorCode {
NifflerError = 100_005,
CsvError = 100_006,
RocksDBError = 100_007,
ZipError = 100_008,
}

#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
Expand Down Expand Up @@ -179,6 +183,8 @@ impl SourmashErrorCode {
#[cfg(not(target_arch = "wasm32"))]
#[cfg(feature = "branchwater")]
SourmashError::RocksDBError { .. } => SourmashErrorCode::RocksDBError,

SourmashError::ZipError { .. } => SourmashErrorCode::ZipError,
}
}
}
2 changes: 1 addition & 1 deletion src/core/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl ZipStorage {
subdir: None,
path: Some(location.as_ref().into()),
}
.try_build().expect("cannot open file as zip file");
.try_build()?;

let subdir = find_subdirs(storage.borrow_archive())?;
storage.with_mut(|fields| *fields.subdir = subdir);
Expand Down

0 comments on commit 3f4bcae

Please sign in to comment.