19 #ifndef INCLUDE_RCF_EXCEPTION_HPP
20 #define INCLUDE_RCF_EXCEPTION_HPP
28 #include <boost/shared_ptr.hpp>
30 #include <RCF/Export.hpp>
31 #include <RCF/Config.hpp>
32 #include <RCF/Tools.hpp>
33 #include <RCF/TypeTraits.hpp>
35 #include <boost/version.hpp>
37 #if RCF_FEATURE_BOOST_SERIALIZATION==1
38 #include <boost/serialization/nvp.hpp>
39 #include <boost/serialization/string.hpp>
40 #include <boost/serialization/vector.hpp>
41 #include <boost/archive/basic_text_iarchive.hpp>
50 RCF_EXPORT std::string toString(
const std::exception &e);
52 class RCF_EXPORT Error
59 Error(
int errorId) : mErrorId(errorId)
65 const std::string & arg1) :
68 mArgs.push_back(arg1);
73 const std::string & arg1,
74 const std::string & arg2) :
77 mArgs.push_back(arg1);
78 mArgs.push_back(arg2);
83 const std::string & arg1,
84 const std::string & arg2,
85 const std::string & arg3) :
88 mArgs.push_back(arg1);
89 mArgs.push_back(arg2);
90 mArgs.push_back(arg3);
93 Error(
const Error & rhs) : mErrorId(rhs.mErrorId), mArgs(rhs.mArgs)
97 int getErrorId()
const
102 void setErrorId(
int errorId)
107 const std::vector<std::string> & getArgs()
const
112 std::string getErrorString()
const;
114 #if RCF_FEATURE_SF==1
115 void serialize(SF::Archive & ar);
118 #if RCF_FEATURE_BOOST_SERIALIZATION==1
119 template<
typename Archive>
120 void serialize(Archive & ar,
const unsigned int)
122 ar & mErrorId & mArgs;
128 const char * getRawErrorString()
const;
131 std::vector<std::string> mArgs;
137 static const int RcfError_Ok = 0;
139 static const int RcfError_ServerMessageLength = 2;
140 static const int RcfError_ClientMessageLength = 3;
141 static const int RcfError_Serialization = 4;
142 static const int RcfError_Deserialization = 5;
143 static const int RcfError_AppException = 6;
144 static const int RcfError_UnknownEndpoint = 8;
145 static const int RcfError_EndpointPassword = 9;
146 static const int RcfError_EndpointDown = 10;
147 static const int RcfError_EndpointRetry = 11;
148 static const int RcfError_ClientConnectTimeout = 16;
149 static const int RcfError_PeerDisconnect = 17;
150 static const int RcfError_ClientCancel = 18;
151 static const int RcfError_PayloadFilterMismatch = 20;
152 static const int RcfError_OpenSslFilterInit = 21;
153 static const int RcfError_OpenSslLoadCert = 22;
154 static const int RcfError_UnknownPublisher = 23;
155 static const int RcfError_UnknownFilter = 24;
156 static const int RcfError_NoServerStub = 25;
157 static const int RcfError_Sspi = 26;
158 static const int RcfError_SspiInit = 28;
159 static const int RcfError_ClientReadTimeout = 30;
160 static const int RcfError_ClientReadFail = 31;
161 static const int RcfError_ClientWriteTimeout = 32;
162 static const int RcfError_ClientWriteFail = 33;
163 static const int RcfError_ClientConnectFail = 34;
164 static const int RcfError_Socket = 36;
165 static const int RcfError_FnId = 37;
166 static const int RcfError_UnknownInterface = 38;
167 static const int RcfError_NoEndpoint = 39;
168 static const int RcfError_TransportCreation = 40;
169 static const int RcfError_FilterCount = 41;
170 static const int RcfError_FilterMessage = 42;
171 static const int RcfError_UnfilterMessage = 43;
172 static const int RcfError_SspiCredentials = 44;
173 static const int RcfError_SspiEncrypt = 45;
174 static const int RcfError_SspiDecrypt = 46;
175 static const int RcfError_SspiImpersonation = 47;
176 static const int RcfError_SocketClose = 49;
177 static const int RcfError_ZlibDeflate = 50;
178 static const int RcfError_ZlibInflate = 51;
179 static const int RcfError_Zlib = 52;
180 static const int RcfError_UnknownSerializationProtocol = 53;
181 static const int SfError_NoCtor = 55;
182 static const int SfError_RefMismatch = 56;
183 static const int SfError_DataFormat = 57;
184 static const int SfError_ReadFailure = 58;
185 static const int SfError_WriteFailure = 59;
186 static const int SfError_BaseDerivedRegistration = 60;
187 static const int SfError_TypeRegistration = 61;
188 static const int RcfError_NonStdException = 62;
189 static const int RcfError_SocketBind = 63;
190 static const int RcfError_Decoding = 64;
191 static const int RcfError_Encoding = 65;
192 static const int RcfError_TokenRequestFailed = 66;
193 static const int RcfError_ObjectFactoryNotFound = 67;
194 static const int RcfError_PortInUse = 68;
195 static const int RcfError_DynamicObjectNotFound = 69;
196 static const int RcfError_VersionMismatch = 70;
197 static const int RcfError_SslCertVerification = 72;
198 static const int RcfError_FiltersLocked = 74;
199 static const int RcfError_Pipe = 75;
200 static const int RcfError_AnySerializerNotFound = 76;
201 static const int RcfError_ConnectionLimitExceeded = 77;
202 static const int RcfError_DeserializationNullPointer = 78;
203 static const int RcfError_PipeNameTooLong = 79;
204 static const int RcfError_PingBack = 80;
205 static const int RcfError_NoPingBackService = 81;
206 static const int RcfError_NoDownload = 82;
207 static const int RcfError_FileOffset = 83;
208 static const int RcfError_NoUpload = 84;
209 static const int RcfError_FileOpen = 85;
210 static const int RcfError_FileRead = 86;
211 static const int RcfError_FileWrite = 87;
212 static const int RcfError_UploadFailed = 88;
213 static const int RcfError_UploadInProgress = 89;
214 static const int RcfError_ConcurrentUpload = 90;
215 static const int RcfError_UploadFileSize = 91;
216 static const int RcfError_AccessDenied = 92;
217 static const int RcfError_PingBackTimeout = 93;
218 static const int RcfError_AllThreadsBusy = 94;
219 static const int RcfError_UnsupportedRuntimeVersion = 95;
220 static const int RcfError_FdSetSize = 97;
221 static const int RcfError_DnsLookup = 98;
222 static const int RcfError_SspiHandshakeExtraData = 99;
223 static const int RcfError_ProtobufWrite = 101;
224 static const int RcfError_ProtobufRead = 102;
225 static const int RcfError_ExtractSlice = 103;
226 static const int RcfError_ServerStubExpired = 104;
227 static const int RcfError_VariantDeserialization = 105;
228 static const int RcfError_SspiAuthFailServer = 106;
229 static const int RcfError_SspiAuthFailClient = 107;
230 static const int RcfError_Win32ApiError = 108;
231 static const int RcfError_SspiLengthField = 109;
232 static const int RcfError_DownloadFailed = 110;
233 static const int RcfError_FileSeek = 111;
234 static const int RcfError_DownloadCancelled = 112;
235 static const int RcfError_ParseSockAddr = 113;
236 static const int RcfError_GetSockName = 114;
237 static const int RcfError_ProtobufWriteSize = 115;
238 static const int RcfError_ProtobufWriteInit = 116;
239 static const int RcfError_ArraySizeMismatch = 117;
240 static const int RcfError_WcharSizeMismatch = 118;
241 static const int RcfError_AnyTypeNotRegistered = 119;
242 static const int RcfError_CryptoApiError = 120;
243 static const int RcfError_ServerStubAccessDenied = 121;
244 static const int RcfError_ApiError = 122;
245 static const int RcfError_HttpProxyPort = 123;
246 static const int RcfError_OpenSslError = 124;
247 static const int RcfError_ProtocolNotSupported = 125;
248 static const int RcfError_ClearCommunicationNotAllowed = 126;
249 static const int RcfError_ThreadingError = 127;
250 static const int RcfError_RcfNotInitialized = 128;
251 static const int RcfError_InvalidHttpMessage = 129;
252 static const int RcfError_HttpRequestContentLength = 130;
253 static const int RcfError_HttpResponseContentLength = 131;
254 static const int RcfError_InvalidOpenSslCertificate = 132;
255 static const int RcfError_InvalidSchannelCertificate = 133;
256 static const int RcfError_HttpConnectFailed = 134;
257 static const int RcfError_SspiImpersonateNoSspi = 135;
258 static const int RcfError_TransportProtocolNotSupported = 136;
259 static const int RcfError_SslNotSupported = 137;
260 static const int RcfError_SessionObjectDoesNotExist = 138;
261 static const int RcfError_UploadAlreadyCompleted = 139;
262 static const int RcfError_FileIndex = 140;
263 static const int RcfError_ConcurrentCalls = 141;
264 static const int RcfError_ParseJsonRpcRequest = 142;
265 static const int RcfError_DllLoad = 143;
266 static const int RcfError_DllFuncLoad = 144;
267 static const int RcfError_UnixDllLoad = 145;
268 static const int RcfError_UnixDllFuncLoad = 146;
269 static const int RcfError_PingBackInterval = 147;
270 static const int RcfError_FileOpenWrite = 148;
271 static const int RcfError_CustomCertValidation = 149;
272 static const int RcfError_SupportedOnWindowsOnly = 150;
273 static const int RcfError_NotSupportedOnWindows = 151;
274 static const int RcfError_NotSupportedInThisBuild = 152;
275 static const int RcfError_NoLongerSupported = 153;
276 static const int RcfError_SslCertVerificationCustom = 154;
277 static const int RcfError_ServerCallbacksNotSupported = 155;
278 static const int RcfError_ServerUnsupportedFeature = 156;
279 static const int RcfError_SyncPublishError = 157;
280 static const int RcfError_DeserializeVectorBool = 158;
281 static const int RcfError_HttpTunnelError = 159;
282 static const int RcfError_HttpSessionTimeout = 160;
283 static const int RcfError_HttpRequestSessionIndex = 161;
284 static const int RcfError_HttpResponseStatus = 162;
285 static const int RcfError_HttpResponseSessionIndex = 163;
286 static const int RcfError_HttpResponseSessionId = 164;
287 static const int RcfError_NotHttpResponse = 165;
288 static const int RcfError_NotHttpPostRequest = 166;
289 static const int RcfError_NotHttpRequest = 167;
290 static const int RcfError_NotSslHandshake = 168;
291 static const int RcfError_ClientStubParms = 169;
292 static const int RcfError_ServerStubParms = 170;
293 static const int RcfError_SessionObjectNotCreated = 171;
294 static const int RcfError_MessageHeaderEncoding = 172;
295 static const int RcfError_OnewayHttp = 173;
296 static const int RcfError_ProxyAuthRetry = 174;
297 static const int RcfError_ProxyCredentialsNeeded = 175;
298 static const int RcfError_ProxyCredentialsInvalid = 176;
301 static const int RcfError_User = 1001;
306 static const int RcfError_StubAssignment = 19;
307 static const int RcfError_SspiAuthFail = 27;
308 static const int RcfError_UnknownSubscriber = 29;
309 static const int RcfError_Filter = 35;
310 static const int RcfError_NotConnected = 48;
311 static const int RcfError_InvalidErrorMessage = 54;
314 #pragma warning(push)
315 #pragma warning(disable:4100)
316 #pragma warning(disable:4267)
320 std::string numberToString(T t)
327 RCF_EXPORT std::string getOsErrorString(
int osError);
329 inline Error _RcfError_Ok() {
return Error(RcfError_Ok); }
331 inline Error _RcfError_ServerMessageLength() {
return Error(RcfError_ServerMessageLength); }
333 inline Error _RcfError_ClientMessageLength() {
return Error(RcfError_ClientMessageLength); }
335 inline Error _RcfError_Serialization(
336 const std::string & typeName,
337 const std::string & eType,
338 const std::string & eWhat) {
return Error(RcfError_Serialization, typeName, eType, eWhat); }
340 inline Error _RcfError_Deserialization(
341 const std::string & typeName,
342 const std::string & eType,
343 const std::string & eWhat) {
return Error(RcfError_Deserialization, typeName, eType, eWhat); }
345 inline Error _RcfError_AppException(
346 const std::string & eType,
347 const std::string & eWhat) {
return Error(RcfError_AppException, eType, eWhat); }
349 inline Error _RcfError_UnknownEndpoint() {
return Error(RcfError_UnknownEndpoint); }
350 inline Error _RcfError_EndpointPassword() {
return Error(RcfError_EndpointPassword); }
351 inline Error _RcfError_EndpointDown() {
return Error(RcfError_EndpointDown); }
352 inline Error _RcfError_EndpointRetry() {
return Error(RcfError_EndpointRetry); }
354 inline Error _RcfError_ClientConnectTimeout(
355 unsigned int timeoutMs,
356 const std::string endpoint) {
return Error(RcfError_ClientConnectTimeout, numberToString(timeoutMs), endpoint); }
358 inline Error _RcfError_PeerDisconnect() {
return Error(RcfError_PeerDisconnect); }
359 inline Error _RcfError_ClientCancel() {
return Error(RcfError_ClientCancel); }
360 inline Error _RcfError_PayloadFilterMismatch() {
return Error(RcfError_PayloadFilterMismatch); }
362 inline Error _RcfError_OpenSslFilterInit(
363 const std::string & opensslErrors) {
return Error(RcfError_OpenSslFilterInit, opensslErrors); }
365 inline Error _RcfError_OpenSslLoadCert(
366 const std::string & file,
367 const std::string & opensslErrors) {
return Error(RcfError_OpenSslLoadCert, file, opensslErrors); }
369 inline Error _RcfError_UnknownPublisher(
370 const std::string & publisherName) {
return Error(RcfError_UnknownPublisher, publisherName); }
372 inline Error _RcfError_UnknownFilter() {
return Error(RcfError_UnknownFilter); }
374 inline Error _RcfError_NoServerStub(
375 const std::string & service,
376 const std::string & interface_,
377 int fnId) {
return Error(RcfError_NoServerStub, service, interface_, numberToString(fnId)); }
379 inline Error _RcfError_Sspi(
380 const std::string & funcName) {
return Error(RcfError_Sspi, funcName); }
382 inline Error _RcfError_SspiInit(
383 const std::string & funcName) {
return Error(RcfError_SspiInit, funcName); }
385 inline Error _RcfError_ClientReadTimeout() {
return Error(RcfError_ClientReadTimeout); }
386 inline Error _RcfError_ClientReadFail() {
return Error(RcfError_ClientReadFail); }
387 inline Error _RcfError_ClientWriteTimeout() {
return Error(RcfError_ClientWriteTimeout); }
388 inline Error _RcfError_ClientWriteFail() {
return Error(RcfError_ClientWriteFail); }
389 inline Error _RcfError_ClientConnectFail() {
return Error(RcfError_ClientConnectFail); }
391 inline Error _RcfError_Socket(
392 const std::string & funcName) {
return Error(RcfError_Socket, funcName); }
394 inline Error _RcfError_FnId(
int fnId) {
return Error(RcfError_FnId, numberToString(fnId)); }
396 inline Error _RcfError_UnknownInterface(
397 const std::string & interface_) {
return Error(RcfError_UnknownInterface, interface_); }
399 inline Error _RcfError_NoEndpoint() {
return Error(RcfError_NoEndpoint); }
400 inline Error _RcfError_TransportCreation() {
return Error(RcfError_TransportCreation); }
402 inline Error _RcfError_FilterCount(
404 std::size_t max) {
return Error(RcfError_FilterCount, numberToString(count), numberToString(max)); }
406 inline Error _RcfError_FilterMessage() {
return Error(RcfError_FilterMessage); }
407 inline Error _RcfError_UnfilterMessage() {
return Error(RcfError_UnfilterMessage); }
409 inline Error _RcfError_SspiCredentials(
410 const std::string & funcName) {
return Error(RcfError_SspiCredentials, funcName); }
412 inline Error _RcfError_SspiEncrypt(
413 const std::string & funcName) {
return Error(RcfError_SspiEncrypt, funcName); }
415 inline Error _RcfError_SspiDecrypt(
416 const std::string & funcName) {
return Error(RcfError_SspiDecrypt, funcName); }
418 inline Error _RcfError_SspiImpersonation(
419 const std::string & funcName) {
return Error(RcfError_SspiImpersonation, funcName); }
421 inline Error _RcfError_SocketClose() {
return Error(RcfError_SocketClose); }
422 inline Error _RcfError_ZlibDeflate() {
return Error(RcfError_ZlibDeflate); }
423 inline Error _RcfError_ZlibInflate() {
return Error(RcfError_ZlibInflate); }
424 inline Error _RcfError_Zlib() {
return Error(RcfError_Zlib); }
426 inline Error _RcfError_UnknownSerializationProtocol(
427 int protocol) {
return Error(RcfError_UnknownSerializationProtocol, numberToString(protocol)); }
429 inline Error _SfError_NoCtor() {
return Error(SfError_NoCtor); }
430 inline Error _SfError_RefMismatch() {
return Error(SfError_RefMismatch); }
431 inline Error _SfError_DataFormat() {
return Error(SfError_DataFormat); }
432 inline Error _SfError_ReadFailure() {
return Error(SfError_ReadFailure); }
433 inline Error _SfError_WriteFailure() {
return Error(SfError_WriteFailure); }
435 inline Error _SfError_BaseDerivedRegistration(
436 const std::string & baseType,
437 const std::string & derivedType) {
return Error(SfError_BaseDerivedRegistration, baseType, derivedType); }
439 inline Error _SfError_TypeRegistration(
440 const std::string & typeName) {
return Error(SfError_TypeRegistration, typeName); }
442 inline Error _RcfError_NonStdException() {
return Error(RcfError_NonStdException); }
444 inline Error _RcfError_SocketBind(
445 const std::string & networkInterface,
446 int port) {
return Error(RcfError_SocketBind, networkInterface, numberToString(port)); }
448 inline Error _RcfError_Decoding() {
return Error(RcfError_Decoding); }
449 inline Error _RcfError_Encoding() {
return Error(RcfError_Encoding); }
450 inline Error _RcfError_TokenRequestFailed() {
return Error(RcfError_TokenRequestFailed); }
451 inline Error _RcfError_ObjectFactoryNotFound() {
return Error(RcfError_ObjectFactoryNotFound); }
453 inline Error _RcfError_PortInUse(
454 const std::string & networkInterface,
455 int port) {
return Error(RcfError_PortInUse, networkInterface, numberToString(port)); }
457 inline Error _RcfError_DynamicObjectNotFound(
458 int tokenId) {
return Error(RcfError_DynamicObjectNotFound, numberToString(tokenId)); }
460 inline Error _RcfError_VersionMismatch() {
return Error(RcfError_VersionMismatch); }
462 inline Error _RcfError_SslCertVerification(
463 const std::string & openSslErr) {
return Error(RcfError_SslCertVerification, openSslErr); }
465 inline Error _RcfError_FiltersLocked() {
return Error(RcfError_FiltersLocked); }
466 inline Error _RcfError_Pipe() {
return Error(RcfError_Pipe); }
468 inline Error _RcfError_AnySerializerNotFound(
469 const std::string & typeName) {
return Error(RcfError_AnySerializerNotFound, typeName); }
471 inline Error _RcfError_ConnectionLimitExceeded() {
return Error(RcfError_ConnectionLimitExceeded); }
472 inline Error _RcfError_DeserializationNullPointer() {
return Error(RcfError_DeserializationNullPointer); }
474 inline Error _RcfError_PipeNameTooLong(
475 const std::string & pipeName,
476 unsigned int max) {
return Error(RcfError_PipeNameTooLong, pipeName, numberToString(max)); }
478 inline Error _RcfError_PingBack() {
return Error(RcfError_PingBack); }
479 inline Error _RcfError_NoPingBackService() {
return Error(RcfError_NoPingBackService); }
480 inline Error _RcfError_NoDownload() {
return Error(RcfError_NoDownload); }
482 inline Error _RcfError_FileOffset(
483 boost::uint64_t expectedPos,
484 boost::uint64_t actualPos) {
return Error(RcfError_FileOffset, numberToString(expectedPos), numberToString(actualPos)); }
486 inline Error _RcfError_NoUpload() {
return Error(RcfError_NoUpload); }
488 inline Error _RcfError_FileOpen(
489 const std::string & filePath) {
return Error(RcfError_FileOpen, filePath); }
491 inline Error _RcfError_FileRead(
492 const std::string & filePath,
493 boost::uint64_t pos) {
return Error(RcfError_FileRead, filePath, numberToString(pos)); }
495 inline Error _RcfError_FileWrite(
496 const std::string & filePath,
497 boost::uint64_t pos) {
return Error(RcfError_FileWrite, filePath, numberToString(pos)); }
499 inline Error _RcfError_UploadFailed() {
return Error(RcfError_UploadFailed); }
500 inline Error _RcfError_UploadInProgress() {
return Error(RcfError_UploadInProgress); }
501 inline Error _RcfError_ConcurrentUpload() {
return Error(RcfError_ConcurrentUpload); }
502 inline Error _RcfError_UploadFileSize() {
return Error(RcfError_UploadFileSize); }
503 inline Error _RcfError_AccessDenied() {
return Error(RcfError_AccessDenied); }
505 inline Error _RcfError_PingBackTimeout(
506 unsigned int pingBackIntervalMs) {
return Error(RcfError_PingBackTimeout, numberToString(pingBackIntervalMs)); }
508 inline Error _RcfError_AllThreadsBusy() {
return Error(RcfError_AllThreadsBusy); }
510 inline Error _RcfError_UnsupportedRuntimeVersion(
511 int requestedVersion,
512 int maxVersion) {
return Error(RcfError_UnsupportedRuntimeVersion, numberToString(requestedVersion), numberToString(maxVersion)); }
514 inline Error _RcfError_FdSetSize(
515 unsigned int max) {
return Error(RcfError_FdSetSize, numberToString(max)); }
517 inline Error _RcfError_DnsLookup(
518 const std::string & ip) {
return Error(RcfError_DnsLookup, ip); }
520 inline Error _RcfError_SspiHandshakeExtraData() {
return Error(RcfError_SspiHandshakeExtraData); }
522 inline Error _RcfError_ProtobufWrite(
523 const std::string & typeName) {
return Error(RcfError_ProtobufWrite, typeName); }
525 inline Error _RcfError_ProtobufRead(
526 const std::string & typeName) {
return Error(RcfError_ProtobufRead, typeName); }
528 inline Error _RcfError_ExtractSlice(
531 std::size_t max) {
return Error(RcfError_ExtractSlice, numberToString(pos), numberToString(len), numberToString(max)); }
533 inline Error _RcfError_ServerStubExpired() {
return Error(RcfError_ServerStubExpired); }
535 inline Error _RcfError_VariantDeserialization(
537 int max) {
return Error(RcfError_VariantDeserialization, numberToString(index), numberToString(max)); }
539 inline Error _RcfError_SspiAuthFailServer() {
return Error(RcfError_SspiAuthFailServer); }
540 inline Error _RcfError_SspiAuthFailClient() {
return Error(RcfError_SspiAuthFailClient); }
542 inline Error _RcfError_Win32ApiError(
543 const std::string & funcName) {
return Error(RcfError_Win32ApiError, funcName); }
545 inline Error _RcfError_SspiLengthField(
547 int maxLength) {
return Error(RcfError_Win32ApiError, numberToString(length), numberToString(maxLength)); }
549 inline Error _RcfError_DownloadFailed(
550 const std::string & errMsg) {
return Error(RcfError_DownloadFailed, errMsg); }
552 inline Error _RcfError_FileSeek(
553 const std::string & filePath,
554 boost::uint64_t offset) {
return Error(RcfError_FileSeek, filePath, numberToString(offset)); }
556 inline Error _RcfError_DownloadCancelled() {
return Error(RcfError_DownloadCancelled); }
558 inline Error _RcfError_ParseSockAddr() {
return Error(RcfError_ParseSockAddr); }
560 inline Error _RcfError_GetSockName() {
return Error(RcfError_GetSockName); }
562 inline Error _RcfError_ProtobufWriteSize(
563 const std::string & typeName) {
return Error(RcfError_ProtobufWriteSize, typeName); }
565 inline Error _RcfError_ProtobufWriteInit(
566 const std::string & typeName) {
return Error(RcfError_ProtobufWriteInit, typeName); }
568 inline Error _RcfError_RcfError_ArraySizeMismatch(
570 unsigned int fromArchive) {
return Error(RcfError_ArraySizeMismatch, numberToString(actual), numberToString(fromArchive)); }
572 inline Error _RcfError_WcharSizeMismatch(
574 unsigned int fromArchive) {
return Error(RcfError_WcharSizeMismatch, numberToString(actual), numberToString(fromArchive)); }
576 inline Error _RcfError_AnyTypeNotRegistered(
577 const std::string typeidName) {
return Error(RcfError_AnyTypeNotRegistered, typeidName); }
579 inline Error _RcfError_CryptoApiError(
580 const std::string & funcName) {
return Error(RcfError_CryptoApiError, funcName); }
582 inline Error _RcfError_ServerStubAccessDenied() {
return Error(RcfError_ServerStubAccessDenied); }
584 inline Error _RcfError_ApiError(
585 const std::string & whichApi) {
return Error(RcfError_ApiError, whichApi); }
587 inline Error _RcfError_HttpProxyPort() {
return Error(RcfError_HttpProxyPort); }
589 inline Error _RcfError_OpenSslError(
590 const std::string & openSslErrors) {
return Error(RcfError_OpenSslError, openSslErrors); }
592 inline Error _RcfError_ProtocolNotSupported() {
return Error(RcfError_ProtocolNotSupported); }
594 inline Error _RcfError_ClearCommunicationNotAllowed(
595 const std::string & protocolNames) {
return Error(RcfError_ClearCommunicationNotAllowed, protocolNames); }
597 inline Error _RcfError_ThreadingError(
598 const std::string & functionName) {
return Error(RcfError_ThreadingError, functionName); }
600 inline Error _RcfError_RcfNotInitialized() {
return Error(RcfError_RcfNotInitialized); }
602 inline Error _RcfError_InvalidHttpMessage() {
return Error(RcfError_InvalidHttpMessage); }
604 inline Error _RcfError_HttpRequestContentLength() {
return Error(RcfError_HttpRequestContentLength); }
606 inline Error _RcfError_HttpResponseContentLength(
607 const std::string & httpStatus,
608 const std::string & httpResponse) {
return Error(RcfError_HttpResponseContentLength, httpStatus, httpResponse); }
610 inline Error _RcfError_InvalidOpenSslCertificate() {
return Error(RcfError_InvalidOpenSslCertificate); }
611 inline Error _RcfError_InvalidSchannelCertificate() {
return Error(RcfError_InvalidSchannelCertificate); }
613 inline Error _RcfError_HttpConnectFailed(
614 const std::string & httpStatus,
615 const std::string & httpResponse) {
return Error(RcfError_HttpConnectFailed, httpStatus, httpResponse); }
617 inline Error _RcfError_SspiImpersonateNoSspi() {
return Error(RcfError_SspiImpersonateNoSspi); }
619 inline Error _RcfError_TransportProtocolNotSupported(
620 const std::string& protocolName) {
return Error(RcfError_TransportProtocolNotSupported, protocolName); }
622 inline Error _RcfError_SslNotSupported() {
return Error(RcfError_SslNotSupported); }
624 inline Error _RcfError_SessionObjectDoesNotExist(
625 const std::string & objectType) {
return Error(RcfError_SessionObjectDoesNotExist, objectType); }
627 inline Error _RcfError_UploadAlreadyCompleted() {
return Error(RcfError_UploadAlreadyCompleted); }
629 inline Error _RcfError_FileIndex(
630 boost::uint64_t expectedPos,
631 boost::uint64_t actualPos) {
return Error(RcfError_FileOffset, numberToString(expectedPos), numberToString(actualPos)); }
633 inline Error _RcfError_ConcurrentCalls() {
return Error(RcfError_ConcurrentCalls); }
635 inline Error _RcfError_ParseJsonRpcRequest() {
return Error(RcfError_ParseJsonRpcRequest); }
637 inline Error _RcfError_DllLoad(
638 const std::string & dllName) {
return Error(RcfError_DllLoad, dllName); }
640 inline Error _RcfError_DllFuncLoad(
641 const std::string & dllName,
642 const std::string & funcName) {
return Error(RcfError_DllFuncLoad, dllName, funcName); }
644 inline Error _RcfError_UnixDllLoad(
645 const std::string & dllName,
646 const std::string & dlerr) {
return Error(RcfError_UnixDllLoad, dllName, dlerr); }
648 inline Error _RcfError_UnixDllFuncLoad(
649 const std::string & dllName,
650 const std::string & funcName,
651 const std::string & dlerr) {
return Error(RcfError_UnixDllFuncLoad, dllName, funcName, dlerr); }
653 inline Error _RcfError_PingBackInterval(
654 boost::uint32_t requestedIntervalMs,
655 boost::uint32_t minimumIntervalMs) {
return Error(RcfError_PingBackInterval, numberToString(requestedIntervalMs), numberToString(minimumIntervalMs) ); }
657 inline Error _RcfError_FileOpenWrite(
658 const std::string & filePath) {
return Error(RcfError_FileOpenWrite, filePath); }
660 inline Error _RcfError_CustomCertValidation(
661 const std::string & errorMsg) {
return Error(RcfError_CustomCertValidation, errorMsg); }
663 inline Error _RcfError_SupportedOnWindowsOnly(
664 const std::string & className) {
return Error(RcfError_SupportedOnWindowsOnly, className); }
666 inline Error _RcfError_NotSupportedOnWindows(
667 const std::string & className) {
return Error(RcfError_NotSupportedOnWindows, className); }
669 inline Error _RcfError_NotSupportedInThisBuild(
670 const std::string & className) {
return Error(RcfError_NotSupportedInThisBuild, className); }
672 inline Error _RcfError_NoLongerSupported(
673 const std::string & s) {
return Error(RcfError_NoLongerSupported, s); }
675 inline Error _RcfError_SslCertVerificationCustom() {
return Error(RcfError_SslCertVerificationCustom); }
677 inline Error _RcfError_ServerCallbacksNotSupported() {
return Error(RcfError_ServerCallbacksNotSupported); }
679 inline Error _RcfError_ServerUnsupportedFeature(
680 const std::string & s) {
return Error(RcfError_ServerUnsupportedFeature, s); }
682 inline Error _RcfError_SyncPublishError(
683 const std::string & s) {
return Error(RcfError_SyncPublishError, s); }
685 inline Error _RcfError_DeserializeVectorBool(
686 boost::uint32_t bitCount,
687 boost::uint32_t bufferSize) {
return Error(RcfError_DeserializeVectorBool, numberToString(bitCount), numberToString(bufferSize)); }
689 inline Error _RcfError_HttpTunnelError(
690 const std::string & errorMsg) {
return Error(RcfError_HttpTunnelError, errorMsg); }
692 inline Error _RcfError_HttpSessionTimeout() {
return Error(RcfError_HttpSessionTimeout); }
694 inline Error _RcfError_HttpRequestSessionIndex(
696 int actualIndex) {
return Error(RcfError_HttpRequestSessionIndex, numberToString(expectedIndex), numberToString(actualIndex)); }
698 inline Error _RcfError_HttpResponseStatus(
699 const std::string & responseLine,
700 const std::string & responseMessage) {
return Error(RcfError_HttpResponseStatus, responseLine, responseMessage); }
702 inline Error _RcfError_HttpResponseSessionIndex(
704 int actualIndex) {
return Error(RcfError_HttpResponseSessionIndex, numberToString(expectedIndex), numberToString(actualIndex)); }
706 inline Error _RcfError_HttpResponseSessionId(
707 const std::string & expectedId,
708 const std::string & actualId) {
return Error(RcfError_HttpResponseSessionId, expectedId, actualId); }
710 inline Error _RcfError_NotHttpResponse() {
return Error(RcfError_NotHttpResponse); }
711 inline Error _RcfError_NotHttpPostRequest() {
return Error(RcfError_NotHttpPostRequest); }
712 inline Error _RcfError_NotHttpRequest() {
return Error(RcfError_NotHttpRequest); }
713 inline Error _RcfError_NotSslHandshake() {
return Error(RcfError_NotSslHandshake); }
714 inline Error _RcfError_ClientStubParms() {
return Error(RcfError_ClientStubParms); }
715 inline Error _RcfError_ServerStubParms() {
return Error(RcfError_ServerStubParms); }
717 inline Error _RcfError_SessionObjectNotCreated(
718 const std::string & objectType) {
return Error(RcfError_SessionObjectNotCreated, objectType); }
720 inline Error _RcfError_MessageHeaderEncoding(
722 std::size_t actualLen) {
return Error(RcfError_MessageHeaderEncoding, numberToString(maxLen), numberToString(actualLen)); }
724 inline Error _RcfError_OnewayHttp() {
return Error(RcfError_OnewayHttp); }
726 inline Error _RcfError_ProxyAuthRetry() {
return Error(RcfError_ProxyAuthRetry); }
727 inline Error _RcfError_ProxyCredentialsNeeded() {
return Error(RcfError_ProxyCredentialsNeeded); }
728 inline Error _RcfError_ProxyCredentialsInvalid() {
return Error(RcfError_ProxyCredentialsInvalid); }
735 static const int RcfSubsystem_None = 0;
736 static const int RcfSubsystem_Os = 1;
737 static const int RcfSubsystem_Zlib = 2;
738 static const int RcfSubsystem_OpenSsl = 3;
739 static const int RcfSubsystem_Asio = 4;
741 RCF_EXPORT std::string getErrorString(
int rcfError);
742 RCF_EXPORT std::string getSubSystemName(
int subSystem);
743 RCF_EXPORT std::string getOsErrorString(
int osError);
745 RCF_EXPORT
bool shouldDisconnectOnRemoteError(
const Error & err);
747 RCF_EXPORT
int getRuntimeVersionOfThisRemoteCall();
749 class RCF_EXPORT Exception :
public std::runtime_error
755 const std::string & what,
756 const std::string & context =
"");
760 const std::string & what =
"",
761 const std::string & context =
"");
766 int subSystem = RcfSubsystem_Os,
767 const std::string & what =
"",
768 const std::string & context =
"");
770 ~Exception() throw();
772 virtual std::auto_ptr<Exception> clone() const;
778 const
char * what() const throw();
779 const Error & getError() const;
780 int getErrorId() const;
781 std::
string getErrorString() const;
782 int getSubSystemError() const;
783 int getSubSystem() const;
784 std::
string getSubSystemName() const;
785 std::
string getContext() const;
786 std::
string getWhat() const;
787 bool getShouldRetry() const;
789 void setContext(const std::
string &context);
790 void setWhat(const std::
string &what);
791 void setShouldRetry(
bool shouldRetry);
793 virtual
void throwSelf() const;
797 std::
string translate() const;
803 std::
string mContext;
810 mutable std::
string mTranslatedWhat;
813 typedef boost::shared_ptr<Exception> ExceptionPtr;
815 class RCF_EXPORT RemoteException : public Exception
822 const std::string & remoteWhat =
"",
823 const std::string & remoteContext =
"",
824 const std::string & remoteExceptionType =
"");
828 int remoteSubSystemError,
830 const std::string & remoteWhat =
"",
831 const std::string & remoteContext =
"",
832 const std::string & remoteExceptionType =
"");
834 ~RemoteException() throw();
836 const
char *what() const throw();
838 std::
string getRemoteExceptionType() const;
840 #if RCF_FEATURE_SF==1
842 void serialize(SF::Archive & ar);
846 #if RCF_FEATURE_BOOST_SERIALIZATION==1
848 template<
typename Archive>
849 void serialize(Archive &ar,
const unsigned int)
851 int runtimeVersion = getRuntimeVersionOfThisRemoteCall();
853 bool isLoading = boost::is_base_and_derived<
854 boost::archive::detail::basic_iarchive, Archive>::value;
856 if (runtimeVersion <= 7)
858 int errorId = mError.getErrorId();
861 & boost::serialization::make_nvp(
"What", mWhat)
862 & boost::serialization::make_nvp(
"Context", mContext)
863 & boost::serialization::make_nvp(
"Error", errorId)
864 & boost::serialization::make_nvp(
"Subsystem Error", mSubSystemError)
865 & boost::serialization::make_nvp(
"Subsystem", mSubSystem)
866 & boost::serialization::make_nvp(
"Remote Exception Type", mRemoteExceptionType);
870 mError.setErrorId(errorId);
876 & boost::serialization::make_nvp(
"What", mWhat)
877 & boost::serialization::make_nvp(
"Context", mContext)
878 & boost::serialization::make_nvp(
"Error", mError)
879 & boost::serialization::make_nvp(
"Subsystem Error", mSubSystemError)
880 & boost::serialization::make_nvp(
"Subsystem", mSubSystem)
881 & boost::serialization::make_nvp(
"Remote Exception Type", mRemoteExceptionType);
887 std::auto_ptr<Exception> clone()
const;
889 void throwSelf()
const;
892 std::string mRemoteExceptionType;
895 #define RCF_DEFINE_EXCEPTION(E, PE) \
896 class E : public PE \
900 const std::string &what = "") : \
901 PE(RcfError_User, what) \
905 const std::string &what = "") : \
910 int subSystemError, \
912 const std::string &what = "") : \
913 PE(error, subSystemError, subSystem, what) \
915 std::auto_ptr<Exception> clone() const \
917 return std::auto_ptr<Exception>( \
920 void throwSelf() const \
928 RCF_DEFINE_EXCEPTION(SerializationException, Exception)
929 RCF_DEFINE_EXCEPTION(AssertionFailureException, Exception)
930 RCF_DEFINE_EXCEPTION(FilterException, Exception)
932 class RCF_EXPORT VersioningException : public RemoteException
936 boost::uint32_t runtimeVersion,
937 boost::uint32_t archiveVersion);
939 ~VersioningException() throw();
941 boost::uint32_t getRuntimeVersion() const;
942 boost::uint32_t getArchiveVersion() const;
944 std::auto_ptr<Exception> clone()
const
946 return std::auto_ptr<Exception>(
947 new VersioningException(*
this));
950 void throwSelf()
const
956 boost::uint32_t mRuntimeVersion;
957 boost::uint32_t mArchiveVersion;
960 #undef RCF_DEFINE_EXCEPTION
964 #endif // ! INCLUDE_RCF_EXCEPTION_HPP