22 #define THROW_IE_EXCEPTION\
23 throw InferenceEngine::details::InferenceEngineException(__FILE__, __LINE__)\
30 #define IE_ASSERT(EXPRESSION)\
31 if (!(EXPRESSION)) throw InferenceEngine::details::InferenceEngineException(__FILE__, __LINE__) << "AssertionFailed: " << #EXPRESSION // NOLINT
34 #define IE_ASSERT(EXPRESSION)\
35 assert((EXPRESSION)); std::stringstream()
45 class InferenceEngineException :
public std::exception {
46 mutable std::string errorDesc;
47 StatusCode status_code =
static_cast<StatusCode
>(0);
50 std::shared_ptr<std::stringstream> exception_stream;
51 bool save_to_status_code =
false;
58 const char *what()
const noexcept
override {
59 if (errorDesc.empty() && exception_stream) {
60 errorDesc = exception_stream->str();
62 errorDesc +=
"\n" + _file +
":" + std::to_string(_line);
65 return errorDesc.c_str();
73 InferenceEngineException(
const std::string &filename,
const int line)
74 : _file(filename), _line(line) {
81 InferenceEngineException(
const InferenceEngineException & that) noexcept {
82 errorDesc = that.errorDesc;
83 status_code = that.status_code;
86 exception_stream = that.exception_stream;
94 InferenceEngineException& operator<<(
const T &arg) {
95 if (save_to_status_code) {
96 auto can_convert = status_code_assign(arg);
97 save_to_status_code =
false;
98 if (can_convert.second) {
99 this->status_code = can_convert.first;
103 if (!exception_stream) {
104 exception_stream.reset(
new std::stringstream());
106 (*exception_stream) << arg;
114 friend InferenceEngineException& as_status(InferenceEngineException& iex) {
115 iex.save_to_status_code =
true;
123 InferenceEngineException& operator<<(InferenceEngineException& (*manip)(InferenceEngineException &)) {
128 bool hasStatus()
const {
129 return this->status_code == 0 ?
false :
true;
133 StatusCode getStatus()
const {
134 return this->status_code;
138 std::pair<StatusCode, bool> status_code_assign(
const StatusCode& status) {
139 return {status,
true};
142 template <
typename T>
143 std::pair<StatusCode, bool> status_code_assign(
const T &) {
144 return {
static_cast<StatusCode
>(0),
false};
148 InferenceEngineException& as_status(InferenceEngineException& iex);
150 static_assert(std::is_nothrow_copy_constructible<InferenceEngineException>::value,
151 "InferenceEngineException must be nothrow copy constructible");
Definition: ie_argmax_layer.hpp:11