Hazelcast C++ Client
ProtocolExceptions.h
1 /*
2  * Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (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  * http://www.apache.org/licenses/LICENSE-2.0
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 //
17 // Created by sancar koyunlu on 23/07/14.
18 //
19 #ifndef HAZELCAST_CLIENT_EXCEPTION_PROTOCOLEXCEPTIONS_H_
20 #define HAZELCAST_CLIENT_EXCEPTION_PROTOCOLEXCEPTIONS_H_
21 
22 #include <stdint.h>
23 
24 #include "hazelcast/client/exception/IException.h"
25 
26 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
27 #pragma warning(push)
28 #pragma warning(disable: 4251) //for dll export
29 #endif
30 
31 namespace hazelcast {
32  namespace client {
33  namespace exception {
34  class HAZELCAST_API ProtocolException : public IException {
35  public:
36  ProtocolException(const std::string& message, const std::string& details, int32_t errorNo,
37  int32_t causeCode)
38  : IException("Cluster", details), errorCode(errorNo), causeErrorCode(causeCode) {
39  }
40 
41  ProtocolException(const std::string& source, const std::string& message)
42  : IException(source, message), errorCode(-1), causeErrorCode(-1) {
43  }
44 
45  int32_t getErrorCode() const {
46  return errorCode;
47  }
48 
49  int32_t getCauseErrorCode() const {
50  return causeErrorCode;
51  }
52  private:
53  int32_t errorCode;
54  int32_t causeErrorCode;
55  };
56 
57 #define DEFINE_PROTOCOL_EXCEPTION(ClassName) \
58  class HAZELCAST_API ClassName : public ProtocolException {\
59  public:\
60  ClassName(const std::string& message, const std::string& details, int32_t errorNo, int32_t causeCode) \
61  : ProtocolException(message, details, errorNo, causeCode) {\
62  }\
63  ClassName(const std::string& source, const std::string& message) \
64  : ProtocolException(source, message) {\
65  }\
66  ClassName(const std::string& source) : ProtocolException(source, "") {\
67  }\
68  virtual void raise() {\
69  throw *this;\
70  }\
71  }\
72 
73  DEFINE_PROTOCOL_EXCEPTION(ArrayIndexOutOfBoundsException);
74  DEFINE_PROTOCOL_EXCEPTION(ArrayStoreException);
75  DEFINE_PROTOCOL_EXCEPTION(AuthenticationException);
76  DEFINE_PROTOCOL_EXCEPTION(CacheNotExistsException);
77  DEFINE_PROTOCOL_EXCEPTION(CallerNotMemberException);
78  DEFINE_PROTOCOL_EXCEPTION(CancellationException);
79  DEFINE_PROTOCOL_EXCEPTION(ClassCastException);
80  DEFINE_PROTOCOL_EXCEPTION(ClassNotFoundException);
81  DEFINE_PROTOCOL_EXCEPTION(ConcurrentModificationException);
82  DEFINE_PROTOCOL_EXCEPTION(ConfigMismatchException);
83  DEFINE_PROTOCOL_EXCEPTION(ConfigurationException);
84  DEFINE_PROTOCOL_EXCEPTION(DistributedObjectDestroyedException);
85  DEFINE_PROTOCOL_EXCEPTION(DuplicateInstanceNameException);
86  DEFINE_PROTOCOL_EXCEPTION(EOFException);
87  DEFINE_PROTOCOL_EXCEPTION(ExecutionException);
88  DEFINE_PROTOCOL_EXCEPTION(HazelcastException);
89  DEFINE_PROTOCOL_EXCEPTION(HazelcastInstanceNotActiveException);
90  DEFINE_PROTOCOL_EXCEPTION(HazelcastOverloadException);
91  DEFINE_PROTOCOL_EXCEPTION(HazelcastSerializationException);
92  DEFINE_PROTOCOL_EXCEPTION(IOException);
93  DEFINE_PROTOCOL_EXCEPTION(IllegalArgumentException);
94  DEFINE_PROTOCOL_EXCEPTION(IllegalAccessException);
95  DEFINE_PROTOCOL_EXCEPTION(IllegalAccessError);
96  DEFINE_PROTOCOL_EXCEPTION(IllegalMonitorStateException);
97  DEFINE_PROTOCOL_EXCEPTION(IllegalStateException);
98  DEFINE_PROTOCOL_EXCEPTION(IllegalThreadStateException);
99  DEFINE_PROTOCOL_EXCEPTION(IndexOutOfBoundsException);
100  DEFINE_PROTOCOL_EXCEPTION(InterruptedException);
101  DEFINE_PROTOCOL_EXCEPTION(InvalidAddressException);
102  DEFINE_PROTOCOL_EXCEPTION(InvalidConfigurationException);
103  DEFINE_PROTOCOL_EXCEPTION(MemberLeftException);
104  DEFINE_PROTOCOL_EXCEPTION(NegativeArraySizeException);
105  DEFINE_PROTOCOL_EXCEPTION(NoSuchElementException);
106  DEFINE_PROTOCOL_EXCEPTION(NotSerializableException);
107  DEFINE_PROTOCOL_EXCEPTION(NullPointerException);
108  DEFINE_PROTOCOL_EXCEPTION(OperationTimeoutException);
109  DEFINE_PROTOCOL_EXCEPTION(PartitionMigratingException);
110  DEFINE_PROTOCOL_EXCEPTION(QueryException);
111  DEFINE_PROTOCOL_EXCEPTION(QueryResultSizeExceededException);
112  DEFINE_PROTOCOL_EXCEPTION(QuorumException);
113  DEFINE_PROTOCOL_EXCEPTION(ReachedMaxSizeException);
114  DEFINE_PROTOCOL_EXCEPTION(RejectedExecutionException);
115  DEFINE_PROTOCOL_EXCEPTION(RemoteMapReduceException);
116  DEFINE_PROTOCOL_EXCEPTION(ResponseAlreadySentException);
117  DEFINE_PROTOCOL_EXCEPTION(RetryableHazelcastException);
118  DEFINE_PROTOCOL_EXCEPTION(RetryableIOException);
119  DEFINE_PROTOCOL_EXCEPTION(RuntimeException);
120  DEFINE_PROTOCOL_EXCEPTION(SecurityException);
121  DEFINE_PROTOCOL_EXCEPTION(SocketException);
125  DEFINE_PROTOCOL_EXCEPTION(StaleSequenceException);
126  DEFINE_PROTOCOL_EXCEPTION(TargetDisconnectedException);
127  DEFINE_PROTOCOL_EXCEPTION(TargetNotMemberException);
128  DEFINE_PROTOCOL_EXCEPTION(TimeoutException);
129  DEFINE_PROTOCOL_EXCEPTION(TopicOverloadException);
130  DEFINE_PROTOCOL_EXCEPTION(TopologyChangedException);
131  DEFINE_PROTOCOL_EXCEPTION(TransactionException);
132  DEFINE_PROTOCOL_EXCEPTION(TransactionNotActiveException);
133  DEFINE_PROTOCOL_EXCEPTION(TransactionTimedOutException);
134  DEFINE_PROTOCOL_EXCEPTION(URISyntaxException);
135  DEFINE_PROTOCOL_EXCEPTION(UTFDataFormatException);
136  DEFINE_PROTOCOL_EXCEPTION(UnsupportedOperationException);
137  DEFINE_PROTOCOL_EXCEPTION(WrongTargetException);
138  DEFINE_PROTOCOL_EXCEPTION(XAException);
139  DEFINE_PROTOCOL_EXCEPTION(AccessControlException);
140  DEFINE_PROTOCOL_EXCEPTION(LoginException);
141  DEFINE_PROTOCOL_EXCEPTION(UnsupportedCallbackException);
142  DEFINE_PROTOCOL_EXCEPTION(NoDataMemberInClusterException);
143  DEFINE_PROTOCOL_EXCEPTION(ReplicatedMapCantBeCreatedOnLiteMemberException);
144  DEFINE_PROTOCOL_EXCEPTION(MaxMessageSizeExceeded);
145  DEFINE_PROTOCOL_EXCEPTION(WANReplicationQueueFullException);
146  DEFINE_PROTOCOL_EXCEPTION(AssertionError);
147  DEFINE_PROTOCOL_EXCEPTION(OutOfMemoryError);
148  DEFINE_PROTOCOL_EXCEPTION(StackOverflowError);
149  DEFINE_PROTOCOL_EXCEPTION(NativeOutOfMemoryError);
150  DEFINE_PROTOCOL_EXCEPTION(ServiceNotFoundException);
151 
152  class HAZELCAST_API UndefinedErrorCodeException : public IException {
153  public:
154  UndefinedErrorCodeException(int32_t errorCode, int64_t correlationId, std::string details)
155  : error(errorCode), messageCallId(correlationId), detailedErrorMessage(details) {
156  }
157 
158  virtual ~UndefinedErrorCodeException() throw() {
159  }
160 
161  int32_t getErrorCode() const {
162  return error;
163  }
164 
165  int64_t getMessageCallId() const {
166  return messageCallId;
167  }
168 
169  const std::string &getDetailedErrorMessage() const {
170  return detailedErrorMessage;
171  }
172 
173  private:
174  int32_t error;
175  int64_t messageCallId;
176  std::string detailedErrorMessage;
177  };
178  }
179  }
180 }
181 
182 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
183 #pragma warning(pop)
184 #endif
185 
186 #endif //HAZELCAST_CLIENT_EXCEPTION_PROTOCOLEXCEPTIONS_H_
Base class for all exception originated from Hazelcast methods.
Definition: IException.h:49
Definition: ProtocolExceptions.h:34
Definition: MapEntryView.h:32