From 53bcf0274f4b7bdec81077b44591af3a932a0270 Mon Sep 17 00:00:00 2001 From: "C. Titus Brown" Date: Wed, 21 Aug 2024 08:10:04 -0700 Subject: [PATCH] provide correct error --- src/core/src/collection.rs | 3 +-- src/core/src/errors.rs | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/src/collection.rs b/src/core/src/collection.rs index bc03274c41..38312f6de1 100644 --- a/src/core/src/collection.rs +++ b/src/core/src/collection.rs @@ -121,8 +121,7 @@ impl Collection { .zip(other.iter()) .all(|((id1, rec1), (id2, rec2))| id1 == id2 && rec1 == rec2) .then(|| self.len()) - // TODO: right error here - .ok_or(Error::MismatchKSizes) + .ok_or(Error::CollectionNotSuperset) } pub fn from_zipfile>(zipfile: P) -> Result { diff --git a/src/core/src/errors.rs b/src/core/src/errors.rs index 90c028eb38..1a61a07041 100644 --- a/src/core/src/errors.rs +++ b/src/core/src/errors.rs @@ -49,6 +49,9 @@ pub enum SourmashError { #[error("error while calculating ANI confidence intervals: {message}")] ANIEstimationError { message: String }, + #[error("collection is not a superset")] + CollectionNotSuperset, + #[error(transparent)] ReadDataError(#[from] ReadDataError), @@ -104,6 +107,7 @@ pub enum SourmashErrorCode { NonEmptyMinHash = 1_06, MismatchNum = 1_07, NeedsAbundanceTracking = 1_08, + CollectionNotSuperset = 1_09, // Input sequence errors InvalidDNA = 11_01, InvalidProt = 11_02, @@ -155,6 +159,7 @@ impl SourmashErrorCode { SourmashError::NifflerError { .. } => SourmashErrorCode::NifflerError, SourmashError::Utf8Error { .. } => SourmashErrorCode::Utf8Error, SourmashError::CsvError { .. } => SourmashErrorCode::CsvError, + SourmashError::CollectionNotSuperset { .. } => SourmashErrorCode::CollectionNotSuperset, #[cfg(not(target_arch = "wasm32"))] #[cfg(feature = "branchwater")]