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
38 NullStream & operator << (
const T &) noexcept {
42 NullStream & operator<< (std::ostream & (*)(std::ostream &)) noexcept {
47 #define IE_ASSERT(EXPRESSION)\
48 assert((EXPRESSION)); NullStream()
58 class InferenceEngineException :
public std::exception {
59 mutable std::string errorDesc;
60 StatusCode status_code =
static_cast<StatusCode
>(0);
63 std::shared_ptr<std::stringstream> exception_stream;
64 bool save_to_status_code =
false;
71 const char *what()
const noexcept
override {
72 if (errorDesc.empty() && exception_stream) {
73 errorDesc = exception_stream->str();
75 errorDesc +=
"\n" + _file +
":" + std::to_string(_line);
78 return errorDesc.c_str();
86 InferenceEngineException(
const std::string &filename,
const int line)
87 : _file(filename), _line(line) {
94 InferenceEngineException(
const InferenceEngineException & that) noexcept {
95 errorDesc = that.errorDesc;
96 status_code = that.status_code;
99 exception_stream = that.exception_stream;
107 InferenceEngineException& operator<<(
const T &arg) {
108 if (save_to_status_code) {
109 auto can_convert = status_code_assign(arg);
110 save_to_status_code =
false;
111 if (can_convert.second) {
112 this->status_code = can_convert.first;
116 if (!exception_stream) {
117 exception_stream.reset(
new std::stringstream());
119 (*exception_stream) << arg;
127 friend InferenceEngineException& as_status(InferenceEngineException& iex) {
128 iex.save_to_status_code =
true;
136 InferenceEngineException& operator<<(InferenceEngineException& (*manip)(InferenceEngineException &)) {
141 bool hasStatus()
const {
142 return this->status_code == 0 ?
false :
true;
146 StatusCode getStatus()
const {
147 return this->status_code;
151 std::pair<StatusCode, bool> status_code_assign(
const StatusCode& status) {
152 return {status,
true};
155 template <
typename T>
156 std::pair<StatusCode, bool> status_code_assign(
const T &) {
157 return {
static_cast<StatusCode
>(0),
false};
161 InferenceEngineException& as_status(InferenceEngineException& iex);
163 static_assert(std::is_nothrow_copy_constructible<InferenceEngineException>::value,
164 "InferenceEngineException must be nothrow copy constructible");
Definition: ie_argmax_layer.hpp:11
Definition: ie_exception.hpp:35