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 
12 #include "ie_common.h"
13 #include "details/ie_exception.hpp"
14 
15 #define CALL_STATUS_FNC(function, ...) \
16  if (!actual) THROW_IE_EXCEPTION << "Wrapper used in the CALL_STATUS_FNC was not initialized."; \
17  ResponseDesc resp; \
18  auto res = actual->function(__VA_ARGS__, &resp); \
19  if (res != OK) InferenceEngine::details::extract_exception(res, resp.msg);
20 
21 #define CALL_STATUS_FNC_NO_ARGS(function) \
22  if (!actual) THROW_IE_EXCEPTION << "Wrapper used in the CALL_STATUS_FNC_NO_ARGS was not initialized."; \
23  ResponseDesc resp; \
24  auto res = actual->function(&resp); \
25  if (res != OK) InferenceEngine::details::extract_exception(res, resp.msg);
26 
27 #define CALL_FNC_NO_ARGS(function) \
28  if (!actual) THROW_IE_EXCEPTION << "Wrapper used in the CALL_FNC_NO_ARGS was not initialized."; \
29  ResponseDesc resp; \
30  auto result = actual->function(&resp); \
31  if (resp.msg[0] != '\0') { \
32  THROW_IE_EXCEPTION << resp.msg; \
33  } \
34  return result;
35 
36 namespace InferenceEngine {
37 namespace details {
38 
39 inline void extract_exception(StatusCode status, const char* msg) {
40  switch (status) {
41  case NOT_IMPLEMENTED:
42  throw NotImplemented(msg);
43  case NETWORK_NOT_LOADED:
44  throw NetworkNotLoaded(msg);
45  case PARAMETER_MISMATCH:
46  throw ParameterMismatch(msg);
47  case NOT_FOUND:
48  throw NotFound(msg);
49  case OUT_OF_BOUNDS:
50  throw OutOfBounds(msg);
51  case UNEXPECTED:
52  throw Unexpected(msg);
53  case REQUEST_BUSY:
54  throw RequestBusy(msg);
55  case RESULT_NOT_READY:
56  throw ResultNotReady(msg);
57  case NOT_ALLOCATED:
58  throw NotAllocated(msg);
59  case INFER_NOT_STARTED:
60  throw InferNotStarted(msg);
61  case NETWORK_NOT_READ:
62  throw NetworkNotRead(msg);
63  case INFER_CANCELLED:
64  throw InferCancelled(msg);
65  default:
66  THROW_IE_EXCEPTION << msg << InferenceEngine::details::as_status << status;
67  }
68 }
69 
70 } // namespace details
71 } // namespace InferenceEngine
This is a header file with common inference engine definitions.
A header file for the main Inference Engine exception.
#define THROW_IE_EXCEPTION
A macro used to throw general exception with a description.
Definition: ie_exception.hpp:25
Inference Engine C++ API.
Definition: cldnn_config.hpp:15
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:224