GridGain C++
ignite_error.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 GridGain Systems, Inc. and Contributors.
3  *
4  * Licensed under the GridGain Community Edition License (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef _IGNITE_IGNITE_ERROR
23 #define _IGNITE_IGNITE_ERROR
24 
25 #include <stdint.h>
26 
27 #include <exception>
28 #include <sstream>
29 
30 #include <ignite/common/common.h>
31 
32 #define IGNITE_ERROR_1(code, part1) { \
33  std::stringstream stream; \
34  stream << (part1); \
35  throw ignite::IgniteError(code, stream.str().c_str()); \
36 }
37 
38 #define IGNITE_ERROR_2(code, part1, part2) { \
39  std::stringstream stream; \
40  stream << (part1) << (part2); \
41  throw ignite::IgniteError(code, stream.str().c_str()); \
42 }
43 
44 #define IGNITE_ERROR_3(code, part1, part2, part3) { \
45  std::stringstream stream; \
46  stream << (part1) << (part2) << (part3); \
47  throw ignite::IgniteError(code, stream.str().c_str()); \
48 }
49 
50 #define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \
51  std::stringstream stream; \
52  stream << msg << " [" << key1 << "=" << (val1) << "]"; \
53  throw ignite::IgniteError(code, stream.str().c_str()); \
54 }
55 
56 #define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
57  std::stringstream stream; \
58  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
59  throw ignite::IgniteError(code, stream.str().c_str()); \
60 }
61 
62 #define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
63  std::stringstream stream; \
64  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
65  throw ignite::IgniteError(code, stream.str().c_str()); \
66 }
67 
68 #define IGNITE_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
69  std::stringstream stream; \
70  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
71  throw ignite::IgniteError(code, stream.str().c_str()); \
72 }
73 
74 #ifdef _MSC_VER
75 # pragma warning(push)
76 # pragma warning(disable : 4275)
77 #endif //_MSC_VER
78 
79 namespace ignite
80 {
81  namespace java
82  {
83  /* JNI error constants. */
84  const int IGNITE_JNI_ERR_SUCCESS = 0;
85  const int IGNITE_JNI_ERR_GENERIC = 1;
86  const int IGNITE_JNI_ERR_JVM_INIT = 2;
87  const int IGNITE_JNI_ERR_JVM_ATTACH = 3;
88  }
89 
93  class IGNITE_IMPORT_EXPORT IgniteError : public std::exception
94  {
95  public:
97  static const int IGNITE_SUCCESS = 0;
98 
100  static const int IGNITE_ERR_JVM_INIT = 1;
101 
103  static const int IGNITE_ERR_JVM_ATTACH = 2;
104 
106  static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3;
107 
109  static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4;
110 
112  static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5;
113 
115  static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
116 
118  static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7;
119 
121  static const int IGNITE_ERR_MEMORY = 1001;
122 
124  static const int IGNITE_ERR_BINARY = 1002;
125 
127  static const int IGNITE_ERR_STD = 1003;
128 
130  static const int IGNITE_ERR_GENERIC = 2000;
131 
133  static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001;
134 
136  static const int IGNITE_ERR_ILLEGAL_STATE = 2002;
137 
139  static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003;
140 
142  static const int IGNITE_ERR_INTERRUPTED = 2004;
143 
145  static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005;
146 
148  static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006;
149 
151  static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
152 
154  static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008;
155 
157  static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009;
158 
160  static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010;
161 
163  static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
164 
166  static const int IGNITE_ERR_CACHE = 2012;
167 
169  static const int IGNITE_ERR_CACHE_LOADER = 2013;
170 
172  static const int IGNITE_ERR_CACHE_WRITER = 2014;
173 
175  static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015;
176 
178  static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
179 
181  static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017;
182 
184  static const int IGNITE_ERR_TX_OPTIMISTIC = 2018;
185 
187  static const int IGNITE_ERR_TX_TIMEOUT = 2019;
188 
190  static const int IGNITE_ERR_TX_ROLLBACK = 2020;
191 
193  static const int IGNITE_ERR_TX_HEURISTIC = 2021;
194 
196  static const int IGNITE_ERR_AUTHENTICATION = 2022;
197 
199  static const int IGNITE_ERR_SECURITY = 2023;
200 
202  static const int IGNITE_ERR_FUTURE_STATE = 2024;
203 
205  static const int IGNITE_ERR_NETWORK_FAILURE = 2025;
206 
208  static const int IGNITE_ERR_SECURE_CONNECTION_FAILURE = 2026;
209 
211  static const int IGNITE_ERR_TX_THIS_THREAD = 2027;
212 
214  static const int IGNITE_ERR_TX = 2028;
215 
216 
218  static const int IGNITE_ERR_UNKNOWN = -1;
219 
225  static void ThrowIfNeeded(const IgniteError& err);
226 
231  IgniteError();
232 
238  IgniteError(const int32_t code);
239 
246  IgniteError(const int32_t code, const char* msg);
247 
253  IgniteError(const IgniteError& other);
254 
261  IgniteError& operator=(const IgniteError& other);
262 
266  ~IgniteError() IGNITE_NO_THROW;
267 
273  int32_t GetCode() const;
274 
280  const char* GetText() const IGNITE_NO_THROW;
281 
288  virtual const char* what() const IGNITE_NO_THROW;
289 
298  static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError& err);
299  private:
301  int32_t code;
302 
304  char* msg;
305  };
306 }
307 
308 #ifdef _MSC_VER
309 # pragma warning(pop)
310 #endif //_MSC_VER
311 
312 #endif //_IGNITE_IGNITE_ERROR
ignite
Ignite API.
Definition: cache.h:47
ignite::IgniteError
Ignite error information.
Definition: ignite_error.h:93