24 #define THROW_IE_EXCEPTION throw InferenceEngine::details::InferenceEngineException(__FILE__, __LINE__)
31 #define IE_ASSERT(EXPRESSION) \
33 throw InferenceEngine::details::InferenceEngineException(__FILE__, __LINE__) \
34 << "AssertionFailed: " << #EXPRESSION // NOLINT
45 NullStream& operator<<(std::ostream& (*)(std::ostream&)) noexcept {
50 #define IE_ASSERT(EXPRESSION) \
51 assert((EXPRESSION)); \
62 class INFERENCE_ENGINE_API_CLASS(InferenceEngineException):
public std::exception {
63 mutable std::string errorDesc;
67 std::shared_ptr<std::stringstream> exception_stream;
68 bool save_to_status_code =
false;
75 const char* what()
const noexcept
override {
76 if (errorDesc.empty() && exception_stream) {
77 errorDesc = exception_stream->str();
79 errorDesc +=
"\n" + _file +
":" + std::to_string(_line);
82 return errorDesc.c_str();
90 InferenceEngineException(
const std::string& filename,
const int line): _file(filename), _line(line) {}
96 InferenceEngineException(
const InferenceEngineException& that) noexcept {
97 errorDesc = that.errorDesc;
98 status_code = that.status_code;
101 exception_stream = that.exception_stream;
109 InferenceEngineException& operator<<(
const T& arg) {
110 if (save_to_status_code) {
111 auto can_convert = status_code_assign(arg);
112 save_to_status_code =
false;
113 if (can_convert.second) {
114 this->status_code = can_convert.first;
118 if (!exception_stream) {
119 exception_stream.reset(
new std::stringstream());
121 (*exception_stream) << arg;
129 friend InferenceEngineException& as_status(InferenceEngineException& iex) {
130 iex.save_to_status_code =
true;
138 InferenceEngineException& operator<<(InferenceEngineException& (*manip)(InferenceEngineException&)) {
143 bool hasStatus()
const {
144 return this->status_code == 0 ?
false :
true;
149 return this->status_code;
152 ~InferenceEngineException() noexcept
override;
155 std::pair<StatusCode, bool> status_code_assign(
const StatusCode& status) {
156 return {status,
true};
159 template <
typename T>
160 std::pair<StatusCode, bool> status_code_assign(
const T&) {
165 InferenceEngineException& as_status(InferenceEngineException& iex);
167 static_assert(std::is_nothrow_copy_constructible<InferenceEngineException>::value,
168 "InferenceEngineException must be nothrow copy constructible");
Inference Engine API.
Definition: ie_argmax_layer.hpp:11
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:212
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
Definition: ie_exception.hpp:38