25 #define THROW_IE_EXCEPTION throw InferenceEngine::details::InferenceEngineException(__FILE__, __LINE__) 32 #define IE_ASSERT(EXPRESSION) \ 34 throw InferenceEngine::details::InferenceEngineException(__FILE__, __LINE__) \ 35 << "AssertionFailed: " << #EXPRESSION // NOLINT 46 NullStream& operator<<(std::ostream& (*)(std::ostream&)) noexcept {
51 #define IE_ASSERT(EXPRESSION) \ 52 assert((EXPRESSION)); \ 63 class INFERENCE_ENGINE_API_CLASS(InferenceEngineException):
public std::exception {
64 mutable std::string errorDesc;
68 std::shared_ptr<std::stringstream> exception_stream;
69 bool save_to_status_code =
false;
76 const char* what()
const noexcept
override {
77 if (errorDesc.empty() && exception_stream) {
78 errorDesc = exception_stream->str();
80 errorDesc +=
"\n" + _file +
":" + std::to_string(_line);
83 return errorDesc.c_str();
91 InferenceEngineException(
const std::string& filename,
const int line): _file(filename), _line(line) {}
97 InferenceEngineException(
const InferenceEngineException& that) noexcept {
98 errorDesc = that.errorDesc;
99 status_code = that.status_code;
102 exception_stream = that.exception_stream;
110 InferenceEngineException& operator<<(
const T& arg) {
111 if (save_to_status_code) {
112 auto can_convert = status_code_assign(arg);
113 save_to_status_code =
false;
114 if (can_convert.second) {
115 this->status_code = can_convert.first;
119 if (!exception_stream) {
120 exception_stream.reset(
new std::stringstream());
122 (*exception_stream) << arg;
130 friend InferenceEngineException& as_status(InferenceEngineException& iex) {
131 iex.save_to_status_code =
true;
139 InferenceEngineException& operator<<(InferenceEngineException& (*manip)(InferenceEngineException&)) {
144 bool hasStatus()
const {
145 return this->status_code == 0 ?
false :
true;
150 return this->status_code;
153 ~InferenceEngineException() noexcept
override;
156 std::pair<StatusCode, bool> status_code_assign(
const StatusCode& status) {
157 return {status,
true};
160 template <
typename T>
161 std::pair<StatusCode, bool> status_code_assign(
const T&) {
166 InferenceEngineException& as_status(InferenceEngineException& iex);
168 static_assert(std::is_nothrow_copy_constructible<InferenceEngineException>::value,
169 "InferenceEngineException must be nothrow copy constructible");
Inference Engine API.
Definition: ie_argmax_layer.hpp:15
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:216
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
Definition: ie_exception.hpp:39