Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
error_impl.cpp
1 /**
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD+Patents license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 // Copyright 2004-present Facebook. All Rights Reserved.
10 // -*- c++ -*-
11 
12 #include "error_c.h"
13 #include "error_impl.h"
14 #include "FaissException.h"
15 #include <exception>
16 
17 thread_local std::exception_ptr faiss_last_exception;
18 
19 const char* faiss_get_last_error() {
20  if (faiss_last_exception) {
21  try {
22  std::rethrow_exception(faiss_last_exception);
23  } catch (std::exception& e) {
24  return e.what();
25  }
26  }
27  return nullptr;
28 }