ie_exception_conversion.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief A header file that provides macros to handle no exception methods
7  *
8  * @file ie_exception_conversion.hpp
9  */
10 #pragma once
11 #include <ie_common.h>
12 
13 #define CALL_STATUS_FNC(function, ...) \
14  if (!actual) THROW_IE_EXCEPTION << "Wrapper used in the CALL_STATUS_FNC was not initialized."; \
15  ResponseDesc resp; \
16  auto res = actual->function(__VA_ARGS__, &resp); \
17  if (res != OK) InferenceEngine::details::extract_exception(res, resp.msg);
18 
19 #define CALL_STATUS_FNC_NO_ARGS(function) \
20  if (!actual) THROW_IE_EXCEPTION << "Wrapper used in the CALL_STATUS_FNC_NO_ARGS was not initialized."; \
21  ResponseDesc resp; \
22  auto res = actual->function(&resp); \
23  if (res != OK) InferenceEngine::details::extract_exception(res, resp.msg);
24 
25 #define CALL_FNC_NO_ARGS(function) \
26  if (!actual) THROW_IE_EXCEPTION << "Wrapper used in the CALL_FNC_NO_ARGS was not initialized."; \
27  ResponseDesc resp; \
28  auto result = actual->function(&resp); \
29  if (resp.msg[0] != '\0') { \
30  THROW_IE_EXCEPTION << resp.msg; \
31  } \
32  return result;
33 
34 namespace InferenceEngine {
35 namespace details {
36 
37 inline void extract_exception(StatusCode status, char* msg) {
38  switch (status) {
39  case NOT_IMPLEMENTED:
40  throw NotImplemented(msg);
41  case NETWORK_NOT_LOADED:
42  throw NetworkNotLoaded(msg);
43  case PARAMETER_MISMATCH:
44  throw ParameterMismatch(msg);
45  case NOT_FOUND:
46  throw NotFound(msg);
47  case OUT_OF_BOUNDS:
48  throw OutOfBounds(msg);
49  case UNEXPECTED:
50  throw Unexpected(msg);
51  case REQUEST_BUSY:
52  throw RequestBusy(msg);
53  case RESULT_NOT_READY:
54  throw ResultNotReady(msg);
55  case NOT_ALLOCATED:
56  throw NotAllocated(msg);
57  case INFER_NOT_STARTED:
58  throw InferNotStarted(msg);
59  case NETWORK_NOT_READ:
60  throw NetworkNotRead(msg);
61  default:
62  THROW_IE_EXCEPTION << msg << InferenceEngine::details::as_status << status;
63  }
64 }
65 
66 } // namespace details
67 } // namespace InferenceEngine
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
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:224
This class represents StatusCode::NETWORK_NOT_READ exception.
Definition: ie_common.h:311
This is a header file with common inference engine definitions.