10 #include "FaissException.h"
15 FaissException::FaissException(
const std::string& m)
19 FaissException::FaissException(
const std::string& m,
23 int size = snprintf(
nullptr, 0,
"Error in %s at %s:%d: %s",
24 funcName, file, line, m.c_str());
26 snprintf(&msg[0], msg.size(),
"Error in %s at %s:%d: %s",
27 funcName, file, line, m.c_str());
36 std::vector<std::pair<int, std::exception_ptr>>& exceptions) {
37 if (exceptions.size() == 1) {
39 std::rethrow_exception(exceptions.front().second);
41 }
else if (exceptions.size() > 1) {
45 for (
auto& p : exceptions) {
47 std::rethrow_exception(p.second);
48 }
catch (std::exception& ex) {
51 ss <<
"Exception thrown from index " << p.first <<
": "
55 ss <<
"Unknown exception thrown from index " << p.first <<
"\n";
58 ss <<
"Unknown exception thrown from index " << p.first <<
"\n";
void handleExceptions(std::vector< std::pair< int, std::exception_ptr >> &exceptions)
const char * what() const noexceptoverride
from std::exception
Base class for Faiss exceptions.