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_ERROR
24 #define _IGNITE_ERROR
25 
26 #include <sstream>
27 #include <stdint.h>
28 
29 #include <ignite/common/common.h>
30 
31 #define IGNITE_ERROR_1(code, part1) { \
32  std::stringstream stream; \
33  stream << (part1); \
34  throw ignite::IgniteError(code, stream.str().c_str()); \
35 }
36 
37 #define IGNITE_ERROR_2(code, part1, part2) { \
38  std::stringstream stream; \
39  stream << (part1) << (part2); \
40  throw ignite::IgniteError(code, stream.str().c_str()); \
41 }
42 
43 #define IGNITE_ERROR_3(code, part1, part2, part3) { \
44  std::stringstream stream; \
45  stream << (part1) << (part2) << (part3); \
46  throw ignite::IgniteError(code, stream.str().c_str()); \
47 }
48 
49 #define IGNITE_ERROR_FORMATTED_1(code, msg, key1, val1) { \
50  std::stringstream stream; \
51  stream << msg << " [" << key1 << "=" << (val1) << "]"; \
52  throw ignite::IgniteError(code, stream.str().c_str()); \
53 }
54 
55 #define IGNITE_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
56  std::stringstream stream; \
57  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
58  throw ignite::IgniteError(code, stream.str().c_str()); \
59 }
60 
61 #define IGNITE_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
62  std::stringstream stream; \
63  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
64  throw ignite::IgniteError(code, stream.str().c_str()); \
65 }
66 
67 #define IGNITE_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
68  std::stringstream stream; \
69  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
70  throw ignite::IgniteError(code, stream.str().c_str()); \
71 }
72 
73 namespace ignite
74 {
78  class IGNITE_IMPORT_EXPORT IgniteError
79  {
80  public:
82  static const int IGNITE_SUCCESS = 0;
83 
85  static const int IGNITE_ERR_JVM_INIT = 1;
86 
88  static const int IGNITE_ERR_JVM_ATTACH = 2;
89 
91  static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3;
92 
94  static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4;
95 
97  static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5;
98 
100  static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
101 
103  static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7;
104 
106  static const int IGNITE_ERR_MEMORY = 1001;
107 
109  static const int IGNITE_ERR_BINARY = 1002;
110 
112  static const int IGNITE_ERR_GENERIC = 2000;
113 
115  static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001;
116 
118  static const int IGNITE_ERR_ILLEGAL_STATE = 2002;
119 
121  static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003;
122 
124  static const int IGNITE_ERR_INTERRUPTED = 2004;
125 
127  static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005;
128 
130  static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006;
131 
133  static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
134 
136  static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008;
137 
139  static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009;
140 
142  static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010;
143 
145  static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
146 
148  static const int IGNITE_ERR_CACHE = 2012;
149 
151  static const int IGNITE_ERR_CACHE_LOADER = 2013;
152 
154  static const int IGNITE_ERR_CACHE_WRITER = 2014;
155 
157  static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015;
158 
160  static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
161 
163  static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017;
164 
166  static const int IGNITE_ERR_TX_OPTIMISTIC = 2018;
167 
169  static const int IGNITE_ERR_TX_TIMEOUT = 2019;
170 
172  static const int IGNITE_ERR_TX_ROLLBACK = 2020;
173 
175  static const int IGNITE_ERR_TX_HEURISTIC = 2021;
176 
178  static const int IGNITE_ERR_AUTHENTICATION = 2022;
179 
181  static const int IGNITE_ERR_SECURITY = 2023;
182 
184  static const int IGNITE_ERR_UNKNOWN = -1;
185 
191  static void ThrowIfNeeded(IgniteError& err);
192 
196  IgniteError();
197 
203  IgniteError(const int32_t code);
204 
211  IgniteError(const int32_t code, const char* msg);
212 
218  IgniteError(const IgniteError& other);
219 
226  IgniteError& operator=(const IgniteError& other);
227 
231  ~IgniteError();
232 
238  int32_t GetCode() const;
239 
245  const char* GetText() const;
246 
255  static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err);
256  private:
258  int32_t code;
259 
261  char* msg;
262  };
263 }
264 
265 #endif
Ignite error information.
Definition: ignite_error.h:78
Apache Ignite API.
Definition: binary_consts.h:28