Skip to content

Commit 967eda6

Browse files
scsiguymeta-codesync[bot]
authored andcommitted
Replace FAISS_ASSERT with FAISS_THROW_FMT for unsupported SVSStorageKind (#5182)
Summary: Pull Request resolved: #5182 The `default` branch of `to_svs_storage_kind()` previously used `FAISS_ASSERT(false && "not supported SVS storage kind")`, which calls `abort()` and tears down the process with no recoverable error. This makes invalid storage kinds — whether from a corrupted index file, a forward-compat mismatch, or a SWIG caller passing a bogus enum value — fatal in a way that cannot be caught by the Python or C++ exception machinery. Replace with `FAISS_THROW_FMT(...)` so the unsupported-kind path raises a `FaissException` that callers can catch, and include the offending integer value in the message to make debugging easier. Reviewed By: mnorris11 Differential Revision: D103914271 fbshipit-source-id: 54d8673d5e533fbdee08262e811de54344b2ca60
1 parent 0320279 commit 967eda6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

faiss/svs/IndexSVSVamana.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <svs/runtime/dynamic_vamana_index.h>
3131

3232
#include <iostream>
33+
#include <type_traits>
3334

3435
namespace faiss {
3536

@@ -76,7 +77,9 @@ inline svs_runtime::StorageKind to_svs_storage_kind(SVSStorageKind kind) {
7677
case SVS_LeanVec8x8:
7778
return svs_runtime::StorageKind::LeanVec8x8;
7879
default:
79-
FAISS_ASSERT(false && "not supported SVS storage kind");
80+
FAISS_THROW_FMT(
81+
"SVSStorageKind (%d) not supported",
82+
static_cast<std::underlying_type_t<SVSStorageKind>>(kind));
8083
}
8184
}
8285

0 commit comments

Comments
 (0)