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