| Apache Ignite C++

ignite_error.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
23 #ifndef _IGNITE_IGNITE_ERROR
24 #define _IGNITE_IGNITE_ERROR
25
26 #include <stdint.h>
27
28 #include <exception>
29 #include <sstream>
30
31 #include <ignite/common/common.h>
32
33 #define IGNITE_ERROR_1(code, part1) { \
34 std::stringstream stream; \
35 stream << (part1); \
36 throw ignite::IgniteError(code, stream.str().c_str()); \
37 }
38
39 #define IGNITE_ERROR_2(code, part1, part2) { \
40 std::stringstream stream; \
41 stream << (part1) << (part2); \
42 throw ignite::IgniteError(code, stream.str().c_str()); \
43 }
44
45 #define IGNITE_ERROR_3(code, part1, part2, part3) { \
46 std::stringstream stream; \
47 stream << (part1) << (part2) << (part3); \
48 throw ignite::IgniteError(code, stream.str().c_str()); \
49 }
50
51 #define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \
52 std::stringstream stream; \
53 stream << msg << " [" << key1 << "=" << (val1) << "]"; \
54 throw ignite::IgniteError(code, stream.str().c_str()); \
55 }
56
57 #define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
58 std::stringstream stream; \
59 stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
60 throw ignite::IgniteError(code, stream.str().c_str()); \
61 }
62
63 #define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
64 std::stringstream stream; \
65 stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
66 throw ignite::IgniteError(code, stream.str().c_str()); \
67 }
68
69 #define IGNITE_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
70 std::stringstream stream; \
71 stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
72 throw ignite::IgniteError(code, stream.str().c_str()); \
73 }
74
75 #ifdef _MSC_VER
76 # pragma warning(push)
77 # pragma warning(disable : 4275)
78 #endif //_MSC_VER
79
80 namespace ignite
81 {
82 namespace java
83 {
84 /* JNI error constants. */
85 const int IGNITE_JNI_ERR_SUCCESS = 0;
86 const int IGNITE_JNI_ERR_GENERIC = 1;
87 const int IGNITE_JNI_ERR_JVM_INIT = 2;
88 const int IGNITE_JNI_ERR_JVM_ATTACH = 3;
89 }
90
94 class IGNITE_IMPORT_EXPORT IgniteError : public std::exception
95 {
96 public:
98 static const int IGNITE_SUCCESS = 0;
99
101 static const int IGNITE_ERR_JVM_INIT = 1;
102
104 static const int IGNITE_ERR_JVM_ATTACH = 2;
105
107 static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3;
108
110 static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4;
111
113 static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5;
114
116 static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
117
119 static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7;
120
122 static const int IGNITE_ERR_MEMORY = 1001;
123
125 static const int IGNITE_ERR_BINARY = 1002;
126
128 static const int IGNITE_ERR_STD = 1003;
129
131 static const int IGNITE_ERR_GENERIC = 2000;
132
134 static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001;
135
137 static const int IGNITE_ERR_ILLEGAL_STATE = 2002;
138
140 static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003;
141
143 static const int IGNITE_ERR_INTERRUPTED = 2004;
144
146 static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005;
147
149 static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006;
150
152 static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
153
155 static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008;
156
158 static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009;
159
161 static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010;
162
164 static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
165
167 static const int IGNITE_ERR_CACHE = 2012;
168
170 static const int IGNITE_ERR_CACHE_LOADER = 2013;
171
173 static const int IGNITE_ERR_CACHE_WRITER = 2014;
174
176 static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015;
177
179 static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
180
182 static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017;
183
185 static const int IGNITE_ERR_TX_OPTIMISTIC = 2018;
186
188 static const int IGNITE_ERR_TX_TIMEOUT = 2019;
189
191 static const int IGNITE_ERR_TX_ROLLBACK = 2020;
192
194 static const int IGNITE_ERR_TX_HEURISTIC = 2021;
195
197 static const int IGNITE_ERR_AUTHENTICATION = 2022;
198
200 static const int IGNITE_ERR_SECURITY = 2023;
201
203 static const int IGNITE_ERR_FUTURE_STATE = 2024;
204
206 static const int IGNITE_ERR_NETWORK_FAILURE = 2025;
207
209 static const int IGNITE_ERR_SECURE_CONNECTION_FAILURE = 2026;
210
212 static const int IGNITE_ERR_TX_THIS_THREAD = 2027;
213
215 static const int IGNITE_ERR_TX = 2028;
216
217
219 static const int IGNITE_ERR_UNKNOWN = -1;
220
226 static void ThrowIfNeeded(const IgniteError& err);
227
232 IgniteError();
233
239 IgniteError(const int32_t code);
240
247 IgniteError(const int32_t code, const char* msg);
248
254 IgniteError(const IgniteError& other);
255
262 IgniteError& operator=(const IgniteError& other);
263
267 ~IgniteError() IGNITE_NO_THROW;
268
274 int32_t GetCode() const;
275
281 const char* GetText() const IGNITE_NO_THROW;
282
289 virtual const char* what() const IGNITE_NO_THROW;
290
299 static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError& err);
300 private:
302 int32_t code;
303
305 char* msg;
306 };
307 }
308
309 #ifdef _MSC_VER
310 # pragma warning(pop)
311 #endif //_MSC_VER
312
313 #endif //_IGNITE_IGNITE_ERROR
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::IgniteError
Ignite error information.
Definition: ignite_error.h:94