GridGain C++ Client Library
grid_error.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) GridGain Systems. All Rights Reserved.
3  * _________ _____ __________________ _____
4  * __ ____/___________(_)______ /__ ____/______ ____(_)_______
5  * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
6  * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
7  * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
8  */
9 
15 #ifndef _GRIDGAIN_GRID_ERROR
16 #define _GRIDGAIN_GRID_ERROR
17 
18 #include <sstream>
19 #include <stdint.h>
20 
21 #include <ignite/common/common.h>
22 
23 #define GG_ERROR_1(code, part1) { \
24  std::stringstream stream; \
25  stream << (part1); \
26  throw gridgain::GridError(code, stream.str().c_str()); \
27 }
28 
29 #define GG_ERROR_2(code, part1, part2) { \
30  std::stringstream stream; \
31  stream << (part1) << (part2); \
32  throw gridgain::GridError(code, stream.str().c_str()); \
33 }
34 
35 #define GG_ERROR_3(code, part1, part2, part3) { \
36  std::stringstream stream; \
37  stream << (part1) << (part2) << (part3); \
38  throw gridgain::GridError(code, stream.str().c_str()); \
39 }
40 
41 #define GG_ERROR_FORMATTED_1(code, msg, key1, val1) { \
42  std::stringstream stream; \
43  stream << msg << " [" << key1 << "=" << (val1) << "]"; \
44  throw gridgain::GridError(code, stream.str().c_str()); \
45 }
46 
47 #define GG_ERROR_FORMATTED_2(code, msg, key1, val1, key2, val2) { \
48  std::stringstream stream; \
49  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << "]"; \
50  throw gridgain::GridError(code, stream.str().c_str()); \
51 }
52 
53 #define GG_ERROR_FORMATTED_3(code, msg, key1, val1, key2, val2, key3, val3) { \
54  std::stringstream stream; \
55  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << "]"; \
56  throw gridgain::GridError(code, stream.str().c_str()); \
57 }
58 
59 #define GG_ERROR_FORMATTED_4(code, msg, key1, val1, key2, val2, key3, val3, key4, val4) { \
60  std::stringstream stream; \
61  stream << msg << " [" << key1 << "=" << (val1) << ", " << key2 << "=" << (val2) << ", " << key3 << "=" << (val3) << ", " << key4 << "=" << (val4) << "]"; \
62  throw gridgain::GridError(code, stream.str().c_str()); \
63 }
64 
65 namespace gridgain
66 {
70  class IGNITE_IMPORT_EXPORT GridError
71  {
72  public:
74  static const int GG_SUCCESS = 0;
75 
77  static const int GG_ERR_JVM_INIT = 1;
78 
80  static const int GG_ERR_JVM_ATTACH = 2;
81 
83  static const int GG_ERR_JVM_LIB_NOT_FOUND = 3;
84 
86  static const int GG_ERR_JVM_LIB_LOAD_FAILED = 4;
87 
89  static const int GG_ERR_JVM_NO_CLASSPATH = 5;
90 
92  static const int GG_ERR_JVM_NO_CLASS_DEF_FOUND = 6;
93 
95  static const int GG_ERR_JVM_NO_SUCH_METHOD = 7;
96 
98  static const int GG_ERR_MEMORY = 1001;
99 
101  static const int GG_ERR_PORTABLE = 1002;
102 
104  static const int GG_ERR_GENERIC = 2000;
105 
107  static const int GG_ERR_ILLEGAL_ARGUMENT = 2001;
108 
110  static const int GG_ERR_ILLEGAL_STATE = 2002;
111 
113  static const int GG_ERR_UNSUPPORTED_OPERATION = 2003;
114 
116  static const int GG_ERR_INTERRUPTED = 2004;
117 
119  static const int GG_ERR_CLUSTER_GROUP_EMPTY = 2005;
120 
122  static const int GG_ERR_CLUSTER_TOPOLOGY = 2006;
123 
125  static const int GG_ERR_COMPUTE_EXECUTION_REJECTED = 2007;
126 
128  static const int GG_ERR_COMPUTE_JOB_FAILOVER = 2008;
129 
131  static const int GG_ERR_COMPUTE_TASK_CANCELLED = 2009;
132 
134  static const int GG_ERR_COMPUTE_TASK_TIMEOUT = 2010;
135 
137  static const int GG_ERR_COMPUTE_USER_UNDECLARED_EXCEPTION = 2011;
138 
140  static const int GG_ERR_CACHE = 2012;
141 
143  static const int GG_ERR_CACHE_LOADER = 2013;
144 
146  static const int GG_ERR_CACHE_WRITER = 2014;
147 
149  static const int GG_ERR_ENTRY_PROCESSOR = 2015;
150 
152  static const int GG_ERR_CACHE_ATOMIC_UPDATE_TIMEOUT = 2016;
153 
155  static const int GG_ERR_CACHE_PARTIAL_UPDATE = 2017;
156 
158  static const int GG_ERR_TX_OPTIMISTIC = 2018;
159 
161  static const int GG_ERR_TX_TIMEOUT = 2019;
162 
164  static const int GG_ERR_TX_ROLLBACK = 2020;
165 
167  static const int GG_ERR_TX_HEURISTIC = 2021;
168 
170  static const int GG_ERR_AUTHENTICATION = 2022;
171 
173  static const int GG_ERR_SECURITY = 2023;
174 
176  static const int GG_ERR_PRODUCT_LICENSE = 2024;
177 
179  static const int GG_ERR_UNKNOWN = -1;
180 
186  static void ThrowIfNeeded(GridError& err);
187 
191  GridError();
192 
198  GridError(const int32_t code);
199 
206  GridError(const int32_t code, const char* msg);
207 
213  GridError(const GridError& other);
214 
221  GridError& operator=(const GridError& other);
222 
226  ~GridError();
227 
233  int32_t GetCode() const;
234 
240  const char* GetText() const;
241 
250  static void SetError(const int jniCode, const char* jniCls, const char* jniMsg, GridError* err);
251  private:
253  int32_t code;
254 
256  char* msg;
257  };
258 }
259 
260 #endif
GridGain API.
Definition: cache.h:35
Grid error information.
Definition: grid_error.h:70