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