forked from facebookresearch/faiss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FaissException.cpp
35 lines (28 loc) · 878 Bytes
/
FaissException.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD+Patents license found in the
* LICENSE file in the root directory of this source tree.
*/
// -*- c++ -*-
#include "FaissException.h"
namespace faiss {
FaissException::FaissException(const std::string& m)
: msg(m) {
}
FaissException::FaissException(const std::string& m,
const char* funcName,
const char* file,
int line) {
int size = snprintf(nullptr, 0, "Error in %s at %s:%d: %s",
funcName, file, line, m.c_str());
msg.resize(size + 1);
snprintf(&msg[0], msg.size(), "Error in %s at %s:%d: %s",
funcName, file, line, m.c_str());
}
const char*
FaissException::what() const noexcept {
return msg.c_str();
}
}