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 namespace ignite
76 {
77  namespace java
78  {
79  /* JNI error constants. */
80  const int IGNITE_JNI_ERR_SUCCESS = 0;
81  const int IGNITE_JNI_ERR_GENERIC = 1;
82  const int IGNITE_JNI_ERR_JVM_INIT = 2;
83  const int IGNITE_JNI_ERR_JVM_ATTACH = 3;
84  }
85 
89  class IGNITE_IMPORT_EXPORT IgniteError : public std::exception
90  {
91  public:
93  static const int IGNITE_SUCCESS = 0;
94 
96  static const int IGNITE_ERR_JVM_INIT = 1;
97 
99  static const int IGNITE_ERR_JVM_ATTACH = 2;
100 
102  static const int IGNITE_ERR_JVM_LIB_NOT_FOUND = 3;
103 
105  static const int IGNITE_ERR_JVM_LIB_LOAD_FAILED = 4;
106 
108  static const int IGNITE_ERR_JVM_NO_CLASSPATH = 5;
109 
111  static const int IGNITE_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
112 
114  static const int IGNITE_ERR_JVM_NO_SUCH_METHOD = 7;
115 
117  static const int IGNITE_ERR_MEMORY = 1001;
118 
120  static const int IGNITE_ERR_BINARY = 1002;
121 
123  static const int IGNITE_ERR_GENERIC = 2000;
124 
126  static const int IGNITE_ERR_ILLEGAL_ARGUMENT = 2001;
127 
129  static const int IGNITE_ERR_ILLEGAL_STATE = 2002;
130 
132  static const int IGNITE_ERR_UNSUPPORTED_OPERATION = 2003;
133 
135  static const int IGNITE_ERR_INTERRUPTED = 2004;
136 
138  static const int IGNITE_ERR_CLUSTER_GROUP_EMPTY = 2005;
139 
141  static const int IGNITE_ERR_CLUSTER_TOPOLOGY = 2006;
142 
144  static const int IGNITE_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
145 
147  static const int IGNITE_ERR_COMPUTE_JOB_FAILOVER = 2008;
148 
150  static const int IGNITE_ERR_COMPUTE_TASK_CANCELLED = 2009;
151 
153  static const int IGNITE_ERR_COMPUTE_TASK_TIMEOUT = 2010;
154 
156  static const int IGNITE_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
157 
159  static const int IGNITE_ERR_CACHE = 2012;
160 
162  static const int IGNITE_ERR_CACHE_LOADER = 2013;
163 
165  static const int IGNITE_ERR_CACHE_WRITER = 2014;
166 
168  static const int IGNITE_ERR_ENTRY_PROCESSOR = 2015;
169 
171  static const int IGNITE_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
172 
174  static const int IGNITE_ERR_CACHE_PARTIAL_UPDATE = 2017;
175 
177  static const int IGNITE_ERR_TX_OPTIMISTIC = 2018;
178 
180  static const int IGNITE_ERR_TX_TIMEOUT = 2019;
181 
183  static const int IGNITE_ERR_TX_ROLLBACK = 2020;
184 
186  static const int IGNITE_ERR_TX_HEURISTIC = 2021;
187 
189  static const int IGNITE_ERR_AUTHENTICATION = 2022;
190 
192  static const int IGNITE_ERR_SECURITY = 2023;
193 
195  static const int IGNITE_ERR_UNKNOWN = -1;
196 
202  static void ThrowIfNeeded(IgniteError& err);
203 
208  IgniteError();
209 
215  IgniteError(const int32_t code);
216 
223  IgniteError(const int32_t code, const char* msg);
224 
230  IgniteError(const IgniteError& other);
231 
238  IgniteError& operator=(const IgniteError& other);
239 
243  ~IgniteError();
244 
250  int32_t GetCode() const;
251 
257  const char* GetText() const IGNITE_NO_THROW;
258 
265  virtual const char* what() const IGNITE_NO_THROW;
266 
275  static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, IgniteError* err);
276  private:
278  int32_t code;
279 
281  char* msg;
282  };
283 }
284 
285 #endif //_IGNITE_IGNITE_ERROR
Ignite error information.
Definition: ignite_error.h:89
Apache Ignite API.
Definition: cache.h:43