| 1 |
/* |
| 2 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 |
* |
| 4 |
* This source code is licensed under the MIT license found in the |
| 5 |
* LICENSE file in the root directory of this source tree. |
| 6 |
*/ |
| 7 |
|
| 8 |
// -*- c++ -*- |
| 9 |
|
| 10 |
#include "error_impl.h" |
| 11 |
#include <faiss/impl/FaissException.h> |
| 12 |
#include <exception> |
| 13 |
#include "error_c.h" |
| 14 |
|
| 15 |
thread_local std::exception_ptr faiss_last_exception; |
| 16 |
|
| 17 |
const char* faiss_get_last_error() { |
| 18 |
if (faiss_last_exception) { |
| 19 |
try { |
| 20 |
std::rethrow_exception(faiss_last_exception); |
| 21 |
} catch (std::exception& e) { |
| 22 |
return e.what(); |
| 23 |
} |
| 24 |
} |
| 25 |
return nullptr; |
| 26 |
} |