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 defined(RCF_USE_BOOST_SERIALIZATION) && BOOST_VERSION > 103301
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 #ifdef RCF_USE_SF_SERIALIZATION
115 void serialize(SF::Archive & ar);
119 #ifdef RCF_USE_BOOST_SERIALIZATION
120 template<
typename Archive>
121 void serialize(Archive & ar,
const unsigned int)
123 ar & mErrorId & mArgs;
129 std::string getRawErrorString()
const;
132 std::vector<std::string> mArgs;
138 static const int RcfError_Ok = 0;
140 static const int RcfError_ServerMessageLength = 2;
141 static const int RcfError_ClientMessageLength = 3;
142 static const int RcfError_Serialization = 4;
143 static const int RcfError_Deserialization = 5;
144 static const int RcfError_AppException = 6;
145 static const int RcfError_UnknownEndpoint = 8;
146 static const int RcfError_EndpointPassword = 9;
147 static const int RcfError_EndpointDown = 10;
148 static const int RcfError_EndpointRetry = 11;
149 static const int RcfError_ClientConnectTimeout = 16;
150 static const int RcfError_PeerDisconnect = 17;
151 static const int RcfError_ClientCancel = 18;
152 static const int RcfError_PayloadFilterMismatch = 20;
153 static const int RcfError_OpenSslFilterInit = 21;
154 static const int RcfError_OpenSslLoadCert = 22;
155 static const int RcfError_UnknownPublisher = 23;
156 static const int RcfError_UnknownFilter = 24;
157 static const int RcfError_NoServerStub = 25;
158 static const int RcfError_Sspi = 26;
159 static const int RcfError_SspiInit = 28;
160 static const int RcfError_ClientReadTimeout = 30;
161 static const int RcfError_ClientReadFail = 31;
162 static const int RcfError_ClientWriteTimeout = 32;
163 static const int RcfError_ClientWriteFail = 33;
164 static const int RcfError_ClientConnectFail = 34;
165 static const int RcfError_Socket = 36;
166 static const int RcfError_FnId = 37;
167 static const int RcfError_UnknownInterface = 38;
168 static const int RcfError_NoEndpoint = 39;
169 static const int RcfError_TransportCreation = 40;
170 static const int RcfError_FilterCount = 41;
171 static const int RcfError_FilterMessage = 42;
172 static const int RcfError_UnfilterMessage = 43;
173 static const int RcfError_SspiCredentials = 44;
174 static const int RcfError_SspiEncrypt = 45;
175 static const int RcfError_SspiDecrypt = 46;
176 static const int RcfError_SspiImpersonation = 47;
177 static const int RcfError_SocketClose = 49;
178 static const int RcfError_ZlibDeflate = 50;
179 static const int RcfError_ZlibInflate = 51;
180 static const int RcfError_Zlib = 52;
181 static const int RcfError_UnknownSerializationProtocol = 53;
182 static const int SfError_NoCtor = 55;
183 static const int SfError_RefMismatch = 56;
184 static const int SfError_DataFormat = 57;
185 static const int SfError_ReadFailure = 58;
186 static const int SfError_WriteFailure = 59;
187 static const int SfError_BaseDerivedRegistration = 60;
188 static const int SfError_TypeRegistration = 61;
189 static const int RcfError_NonStdException = 62;
190 static const int RcfError_SocketBind = 63;
191 static const int RcfError_Decoding = 64;
192 static const int RcfError_Encoding = 65;
193 static const int RcfError_TokenRequestFailed = 66;
194 static const int RcfError_ObjectFactoryNotFound = 67;
195 static const int RcfError_PortInUse = 68;
196 static const int RcfError_DynamicObjectNotFound = 69;
197 static const int RcfError_VersionMismatch = 70;
198 static const int RcfError_SslCertVerification = 72;
199 static const int RcfError_FiltersLocked = 74;
200 static const int RcfError_Pipe = 75;
201 static const int RcfError_AnySerializerNotFound = 76;
202 static const int RcfError_ConnectionLimitExceeded = 77;
203 static const int RcfError_DeserializationNullPointer = 78;
204 static const int RcfError_PipeNameTooLong = 79;
205 static const int RcfError_PingBack = 80;
206 static const int RcfError_NoPingBackService = 81;
207 static const int RcfError_NoDownload = 82;
208 static const int RcfError_FileOffset = 83;
209 static const int RcfError_NoUpload = 84;
210 static const int RcfError_FileOpen = 85;
211 static const int RcfError_FileRead = 86;
212 static const int RcfError_FileWrite = 87;
213 static const int RcfError_UploadFailed = 88;
214 static const int RcfError_UploadInProgress = 89;
215 static const int RcfError_ConcurrentUpload = 90;
216 static const int RcfError_UploadFileSize = 91;
217 static const int RcfError_AccessDenied = 92;
218 static const int RcfError_PingBackTimeout = 93;
219 static const int RcfError_AllThreadsBusy = 94;
220 static const int RcfError_UnsupportedRuntimeVersion = 95;
221 static const int RcfError_FdSetSize = 97;
222 static const int RcfError_DnsLookup = 98;
223 static const int RcfError_SspiHandshakeExtraData = 99;
224 static const int RcfError_ProtobufWrite = 101;
225 static const int RcfError_ProtobufRead = 102;
226 static const int RcfError_ExtractSlice = 103;
227 static const int RcfError_ServerStubExpired = 104;
228 static const int RcfError_VariantDeserialization = 105;
229 static const int RcfError_SspiAuthFailServer = 106;
230 static const int RcfError_SspiAuthFailClient = 107;
231 static const int RcfError_Win32ApiError = 108;
232 static const int RcfError_SspiLengthField = 109;
233 static const int RcfError_DownloadFailed = 110;
234 static const int RcfError_FileSeek = 111;
235 static const int RcfError_DownloadCancelled = 112;
236 static const int RcfError_ParseSockAddr = 113;
237 static const int RcfError_GetSockName = 114;
238 static const int RcfError_ProtobufWriteSize = 115;
239 static const int RcfError_ProtobufWriteInit = 116;
240 static const int RcfError_ArraySizeMismatch = 117;
241 static const int RcfError_WcharSizeMismatch = 118;
242 static const int RcfError_AnyTypeNotRegistered = 119;
243 static const int RcfError_CryptoApiError = 120;
244 static const int RcfError_ServerStubAccessDenied = 121;
245 static const int RcfError_ApiError = 122;
246 static const int RcfError_HttpProxyPort = 123;
247 static const int RcfError_OpenSslError = 124;
248 static const int RcfError_ProtocolNotSupported = 125;
249 static const int RcfError_ClearCommunicationNotAllowed = 126;
250 static const int RcfError_ThreadingError = 127;
251 static const int RcfError_RcfNotInitialized = 128;
252 static const int RcfError_InvalidHttpMessage = 129;
253 static const int RcfError_HttpRequestContentLength = 130;
254 static const int RcfError_HttpResponseContentLength = 131;
255 static const int RcfError_InvalidOpenSslCertificate = 132;
256 static const int RcfError_InvalidSchannelCertificate = 133;
257 static const int RcfError_HttpConnectFailed = 134;
258 static const int RcfError_SspiImpersonateNoSspi = 135;
259 static const int RcfError_TransportProtocolNotSupported = 136;
260 static const int RcfError_SslNotSupported = 137;
261 static const int RcfError_SessionObjectDoesNotExist = 138;
262 static const int RcfError_UploadAlreadyCompleted = 139;
263 static const int RcfError_FileIndex = 140;
264 static const int RcfError_ConcurrentCalls = 141;
265 static const int RcfError_ParseJsonRpcRequest = 142;
266 static const int RcfError_DllLoad = 143;
267 static const int RcfError_DllFuncLoad = 144;
268 static const int RcfError_UnixDllLoad = 145;
269 static const int RcfError_UnixDllFuncLoad = 146;
270 static const int RcfError_PingBackInterval = 147;
271 static const int RcfError_FileOpenWrite = 148;
272 static const int RcfError_CustomCertValidation = 149;
273 static const int RcfError_SupportedOnWindowsOnly = 150;
274 static const int RcfError_NotSupportedOnWindows = 151;
275 static const int RcfError_NotSupportedInThisBuild = 152;
278 static const int RcfError_User = 1001;
283 static const int RcfError_StubAssignment = 19;
284 static const int RcfError_SspiAuthFail = 27;
285 static const int RcfError_UnknownSubscriber = 29;
286 static const int RcfError_Filter = 35;
287 static const int RcfError_NotConnected = 48;
288 static const int RcfError_InvalidErrorMessage = 54;
291 #pragma warning(push)
292 #pragma warning(disable:4100)
293 #pragma warning(disable:4267)
297 std::string numberToString(T t)
299 std::ostringstream os;
304 RCF_EXPORT std::string getOsErrorString(
int osError);
306 inline Error _RcfError_Ok() {
return Error(RcfError_Ok); }
308 inline Error _RcfError_ServerMessageLength() {
return Error(RcfError_ServerMessageLength); }
310 inline Error _RcfError_ClientMessageLength(
311 boost::uint32_t length,
312 std::size_t maxLength) {
return Error(RcfError_ClientMessageLength, numberToString(length), numberToString(maxLength)); }
314 inline Error _RcfError_Serialization(
315 const std::string & typeName,
316 const std::string & eType,
317 const std::string & eWhat) {
return Error(RcfError_Serialization, typeName, eType, eWhat); }
319 inline Error _RcfError_Deserialization(
320 const std::string & typeName,
321 const std::string & eType,
322 const std::string & eWhat) {
return Error(RcfError_Deserialization, typeName, eType, eWhat); }
324 inline Error _RcfError_AppException(
325 const std::string & eType,
326 const std::string & eWhat) {
return Error(RcfError_AppException, eType, eWhat); }
328 inline Error _RcfError_UnknownEndpoint() {
return Error(RcfError_UnknownEndpoint); }
329 inline Error _RcfError_EndpointPassword() {
return Error(RcfError_EndpointPassword); }
330 inline Error _RcfError_EndpointDown() {
return Error(RcfError_EndpointDown); }
331 inline Error _RcfError_EndpointRetry() {
return Error(RcfError_EndpointRetry); }
333 inline Error _RcfError_ClientConnectTimeout(
334 unsigned int timeoutMs,
335 const std::string endpoint) {
return Error(RcfError_ClientConnectTimeout, numberToString(timeoutMs), endpoint); }
337 inline Error _RcfError_PeerDisconnect() {
return Error(RcfError_PeerDisconnect); }
338 inline Error _RcfError_ClientCancel() {
return Error(RcfError_ClientCancel); }
339 inline Error _RcfError_PayloadFilterMismatch() {
return Error(RcfError_PayloadFilterMismatch); }
341 inline Error _RcfError_OpenSslFilterInit(
342 const std::string & opensslErrors) {
return Error(RcfError_OpenSslFilterInit, opensslErrors); }
344 inline Error _RcfError_OpenSslLoadCert(
345 const std::string & file,
346 const std::string & opensslErrors) {
return Error(RcfError_OpenSslLoadCert, file, opensslErrors); }
348 inline Error _RcfError_UnknownPublisher(
349 const std::string & publisherName) {
return Error(RcfError_UnknownPublisher, publisherName); }
351 inline Error _RcfError_UnknownFilter() {
return Error(RcfError_UnknownFilter); }
353 inline Error _RcfError_NoServerStub(
354 const std::string & service,
355 const std::string & interface_,
356 int fnId) {
return Error(RcfError_NoServerStub, service, interface_, numberToString(fnId)); }
358 inline Error _RcfError_Sspi(
359 const std::string & funcName) {
return Error(RcfError_Sspi, funcName); }
361 inline Error _RcfError_SspiInit(
362 const std::string & funcName) {
return Error(RcfError_SspiInit, funcName); }
364 inline Error _RcfError_ClientReadTimeout() {
return Error(RcfError_ClientReadTimeout); }
365 inline Error _RcfError_ClientReadFail() {
return Error(RcfError_ClientReadFail); }
366 inline Error _RcfError_ClientWriteTimeout() {
return Error(RcfError_ClientWriteTimeout); }
367 inline Error _RcfError_ClientWriteFail() {
return Error(RcfError_ClientWriteFail); }
368 inline Error _RcfError_ClientConnectFail() {
return Error(RcfError_ClientConnectFail); }
370 inline Error _RcfError_Socket(
371 const std::string & funcName) {
return Error(RcfError_Socket, funcName); }
373 inline Error _RcfError_FnId(
int fnId) {
return Error(RcfError_FnId, numberToString(fnId)); }
375 inline Error _RcfError_UnknownInterface(
376 const std::string & interface_) {
return Error(RcfError_UnknownInterface, interface_); }
378 inline Error _RcfError_NoEndpoint() {
return Error(RcfError_NoEndpoint); }
379 inline Error _RcfError_TransportCreation() {
return Error(RcfError_TransportCreation); }
381 inline Error _RcfError_FilterCount(
383 std::size_t max) {
return Error(RcfError_FilterCount, numberToString(count), numberToString(max)); }
385 inline Error _RcfError_FilterMessage() {
return Error(RcfError_FilterMessage); }
386 inline Error _RcfError_UnfilterMessage() {
return Error(RcfError_UnfilterMessage); }
388 inline Error _RcfError_SspiCredentials(
389 const std::string & funcName) {
return Error(RcfError_SspiCredentials, funcName); }
391 inline Error _RcfError_SspiEncrypt(
392 const std::string & funcName) {
return Error(RcfError_SspiEncrypt, funcName); }
394 inline Error _RcfError_SspiDecrypt(
395 const std::string & funcName) {
return Error(RcfError_SspiDecrypt, funcName); }
397 inline Error _RcfError_SspiImpersonation(
398 const std::string & funcName) {
return Error(RcfError_SspiImpersonation, funcName); }
400 inline Error _RcfError_SocketClose() {
return Error(RcfError_SocketClose); }
401 inline Error _RcfError_ZlibDeflate() {
return Error(RcfError_ZlibDeflate); }
402 inline Error _RcfError_ZlibInflate() {
return Error(RcfError_ZlibInflate); }
403 inline Error _RcfError_Zlib() {
return Error(RcfError_Zlib); }
405 inline Error _RcfError_UnknownSerializationProtocol(
406 int protocol) {
return Error(RcfError_UnknownSerializationProtocol, numberToString(protocol)); }
408 inline Error _SfError_NoCtor() {
return Error(SfError_NoCtor); }
409 inline Error _SfError_RefMismatch() {
return Error(SfError_RefMismatch); }
410 inline Error _SfError_DataFormat() {
return Error(SfError_DataFormat); }
411 inline Error _SfError_ReadFailure() {
return Error(SfError_ReadFailure); }
412 inline Error _SfError_WriteFailure() {
return Error(SfError_WriteFailure); }
414 inline Error _SfError_BaseDerivedRegistration(
415 const std::string & baseType,
416 const std::string & derivedType) {
return Error(SfError_BaseDerivedRegistration, baseType, derivedType); }
418 inline Error _SfError_TypeRegistration(
419 const std::string & typeName) {
return Error(SfError_TypeRegistration, typeName); }
421 inline Error _RcfError_NonStdException() {
return Error(RcfError_NonStdException); }
423 inline Error _RcfError_SocketBind(
424 const std::string & networkInterface,
425 int port) {
return Error(RcfError_SocketBind, networkInterface, numberToString(port)); }
427 inline Error _RcfError_Decoding() {
return Error(RcfError_Decoding); }
428 inline Error _RcfError_Encoding() {
return Error(RcfError_Encoding); }
429 inline Error _RcfError_TokenRequestFailed() {
return Error(RcfError_TokenRequestFailed); }
430 inline Error _RcfError_ObjectFactoryNotFound() {
return Error(RcfError_ObjectFactoryNotFound); }
432 inline Error _RcfError_PortInUse(
433 const std::string & networkInterface,
434 int port) {
return Error(RcfError_PortInUse, networkInterface, numberToString(port)); }
436 inline Error _RcfError_DynamicObjectNotFound(
437 int tokenId) {
return Error(RcfError_DynamicObjectNotFound, numberToString(tokenId)); }
439 inline Error _RcfError_VersionMismatch() {
return Error(RcfError_VersionMismatch); }
440 inline Error _RcfError_SslCertVerification() {
return Error(RcfError_SslCertVerification); }
441 inline Error _RcfError_FiltersLocked() {
return Error(RcfError_FiltersLocked); }
442 inline Error _RcfError_Pipe() {
return Error(RcfError_Pipe); }
444 inline Error _RcfError_AnySerializerNotFound(
445 const std::string & typeName) {
return Error(RcfError_AnySerializerNotFound, typeName); }
447 inline Error _RcfError_ConnectionLimitExceeded() {
return Error(RcfError_ConnectionLimitExceeded); }
448 inline Error _RcfError_DeserializationNullPointer() {
return Error(RcfError_DeserializationNullPointer); }
450 inline Error _RcfError_PipeNameTooLong(
451 const std::string & pipeName,
452 unsigned int max) {
return Error(RcfError_PipeNameTooLong, pipeName, numberToString(max)); }
454 inline Error _RcfError_PingBack() {
return Error(RcfError_PingBack); }
455 inline Error _RcfError_NoPingBackService() {
return Error(RcfError_NoPingBackService); }
456 inline Error _RcfError_NoDownload() {
return Error(RcfError_NoDownload); }
458 inline Error _RcfError_FileOffset(
459 boost::uint64_t expectedPos,
460 boost::uint64_t actualPos) {
return Error(RcfError_FileOffset, numberToString(expectedPos), numberToString(actualPos)); }
462 inline Error _RcfError_NoUpload() {
return Error(RcfError_NoUpload); }
464 inline Error _RcfError_FileOpen(
465 const std::string & filePath) {
return Error(RcfError_FileOpen, filePath); }
467 inline Error _RcfError_FileRead(
468 const std::string & filePath,
469 boost::uint64_t pos) {
return Error(RcfError_FileRead, filePath, numberToString(pos)); }
471 inline Error _RcfError_FileWrite(
472 const std::string & filePath,
473 boost::uint64_t pos) {
return Error(RcfError_FileWrite, filePath, numberToString(pos)); }
475 inline Error _RcfError_UploadFailed() {
return Error(RcfError_UploadFailed); }
476 inline Error _RcfError_UploadInProgress() {
return Error(RcfError_UploadInProgress); }
477 inline Error _RcfError_ConcurrentUpload() {
return Error(RcfError_ConcurrentUpload); }
478 inline Error _RcfError_UploadFileSize() {
return Error(RcfError_UploadFileSize); }
479 inline Error _RcfError_AccessDenied() {
return Error(RcfError_AccessDenied); }
481 inline Error _RcfError_PingBackTimeout(
482 unsigned int pingBackIntervalMs) {
return Error(RcfError_PingBackTimeout, numberToString(pingBackIntervalMs)); }
484 inline Error _RcfError_AllThreadsBusy() {
return Error(RcfError_AllThreadsBusy); }
486 inline Error _RcfError_UnsupportedRuntimeVersion(
487 int requestedVersion,
488 int maxVersion) {
return Error(RcfError_UnsupportedRuntimeVersion, numberToString(requestedVersion), numberToString(maxVersion)); }
490 inline Error _RcfError_FdSetSize(
491 unsigned int max) {
return Error(RcfError_FdSetSize, numberToString(max)); }
493 inline Error _RcfError_DnsLookup(
494 const std::string & ip) {
return Error(RcfError_DnsLookup, ip); }
496 inline Error _RcfError_SspiHandshakeExtraData() {
return Error(RcfError_SspiHandshakeExtraData); }
498 inline Error _RcfError_ProtobufWrite(
499 const std::string & typeName) {
return Error(RcfError_ProtobufWrite, typeName); }
501 inline Error _RcfError_ProtobufRead(
502 const std::string & typeName) {
return Error(RcfError_ProtobufRead, typeName); }
504 inline Error _RcfError_ExtractSlice(
507 std::size_t max) {
return Error(RcfError_ExtractSlice, numberToString(pos), numberToString(len), numberToString(max)); }
509 inline Error _RcfError_ServerStubExpired() {
return Error(RcfError_ServerStubExpired); }
511 inline Error _RcfError_VariantDeserialization(
513 int max) {
return Error(RcfError_VariantDeserialization, numberToString(index), numberToString(max)); }
515 inline Error _RcfError_SspiAuthFailServer() {
return Error(RcfError_SspiAuthFailServer); }
516 inline Error _RcfError_SspiAuthFailClient() {
return Error(RcfError_SspiAuthFailClient); }
518 inline Error _RcfError_Win32ApiError(
519 const std::string & funcName) {
return Error(RcfError_Win32ApiError, funcName); }
521 inline Error _RcfError_SspiLengthField(
523 int maxLength) {
return Error(RcfError_Win32ApiError, numberToString(length), numberToString(maxLength)); }
525 inline Error _RcfError_DownloadFailed(
526 const std::string & errMsg) {
return Error(RcfError_DownloadFailed, errMsg); }
528 inline Error _RcfError_FileSeek(
529 const std::string & filePath,
530 boost::uint64_t offset) {
return Error(RcfError_FileSeek, filePath, numberToString(offset)); }
532 inline Error _RcfError_DownloadCancelled() {
return Error(RcfError_DownloadCancelled); }
534 inline Error _RcfError_ParseSockAddr() {
return Error(RcfError_ParseSockAddr); }
536 inline Error _RcfError_GetSockName() {
return Error(RcfError_GetSockName); }
538 inline Error _RcfError_ProtobufWriteSize(
539 const std::string & typeName) {
return Error(RcfError_ProtobufWriteSize, typeName); }
541 inline Error _RcfError_ProtobufWriteInit(
542 const std::string & typeName) {
return Error(RcfError_ProtobufWriteInit, typeName); }
544 inline Error _RcfError_RcfError_ArraySizeMismatch(
546 unsigned int fromArchive) {
return Error(RcfError_ArraySizeMismatch, numberToString(actual), numberToString(fromArchive)); }
548 inline Error _RcfError_WcharSizeMismatch(
550 unsigned int fromArchive) {
return Error(RcfError_WcharSizeMismatch, numberToString(actual), numberToString(fromArchive)); }
552 inline Error _RcfError_AnyTypeNotRegistered(
553 const std::string typeidName) {
return Error(RcfError_AnyTypeNotRegistered, typeidName); }
555 inline Error _RcfError_CryptoApiError(
556 const std::string & funcName) {
return Error(RcfError_CryptoApiError, funcName); }
558 inline Error _RcfError_ServerStubAccessDenied() {
return Error(RcfError_ServerStubAccessDenied); }
560 inline Error _RcfError_ApiError(
561 const std::string & whichApi) {
return Error(RcfError_ApiError, whichApi); }
563 inline Error _RcfError_HttpProxyPort() {
return Error(RcfError_HttpProxyPort); }
565 inline Error _RcfError_OpenSslError(
566 const std::string & openSslErrors) {
return Error(RcfError_OpenSslError, openSslErrors); }
568 inline Error _RcfError_ProtocolNotSupported() {
return Error(RcfError_ProtocolNotSupported); }
570 inline Error _RcfError_ClearCommunicationNotAllowed(
571 const std::string & protocolNames) {
return Error(RcfError_ClearCommunicationNotAllowed, protocolNames); }
573 inline Error _RcfError_ThreadingError(
574 const std::string & functionName) {
return Error(RcfError_ThreadingError, functionName); }
576 inline Error _RcfError_RcfNotInitialized() {
return Error(RcfError_RcfNotInitialized); }
578 inline Error _RcfError_InvalidHttpMessage() {
return Error(RcfError_InvalidHttpMessage); }
580 inline Error _RcfError_HttpRequestContentLength(
581 const std::string & httpRequest) {
return Error(RcfError_HttpRequestContentLength, httpRequest); }
583 inline Error _RcfError_HttpResponseContentLength(
584 const std::string & httpStatus,
585 const std::string & httpResponse) {
return Error(RcfError_HttpResponseContentLength, httpStatus, httpResponse); }
587 inline Error _RcfError_InvalidOpenSslCertificate() {
return Error(RcfError_InvalidOpenSslCertificate); }
588 inline Error _RcfError_InvalidSchannelCertificate() {
return Error(RcfError_InvalidSchannelCertificate); }
590 inline Error _RcfError_HttpConnectFailed(
591 const std::string & httpStatus,
592 const std::string & httpResponse) {
return Error(RcfError_HttpConnectFailed, httpStatus, httpResponse); }
594 inline Error _RcfError_SspiImpersonateNoSspi() {
return Error(RcfError_SspiImpersonateNoSspi); }
596 inline Error _RcfError_TransportProtocolNotSupported(
597 const std::string& protocolName) {
return Error(RcfError_TransportProtocolNotSupported, protocolName); }
599 inline Error _RcfError_SslNotSupported() {
return Error(RcfError_SslNotSupported); }
601 inline Error _RcfError_SessionObjectDoesNotExist(
602 const std::string & objectType) {
return Error(RcfError_SessionObjectDoesNotExist, objectType); }
604 inline Error _RcfError_UploadAlreadyCompleted() {
return Error(RcfError_UploadAlreadyCompleted); }
606 inline Error _RcfError_FileIndex(
607 boost::uint64_t expectedPos,
608 boost::uint64_t actualPos) {
return Error(RcfError_FileOffset, numberToString(expectedPos), numberToString(actualPos)); }
610 inline Error _RcfError_ConcurrentCalls() {
return Error(RcfError_ConcurrentCalls); }
612 inline Error _RcfError_ParseJsonRpcRequest() {
return Error(RcfError_ParseJsonRpcRequest); }
614 inline Error _RcfError_DllLoad(
615 const std::string & dllName) {
return Error(RcfError_DllLoad, dllName); }
617 inline Error _RcfError_DllFuncLoad(
618 const std::string & dllName,
619 const std::string & funcName) {
return Error(RcfError_DllFuncLoad, dllName, funcName); }
621 inline Error _RcfError_UnixDllLoad(
622 const std::string & dllName,
623 const std::string & dlerr) {
return Error(RcfError_UnixDllLoad, dllName, dlerr); }
625 inline Error _RcfError_UnixDllFuncLoad(
626 const std::string & dllName,
627 const std::string & funcName,
628 const std::string & dlerr) {
return Error(RcfError_UnixDllFuncLoad, dllName, funcName, dlerr); }
630 inline Error _RcfError_PingBackInterval(
631 boost::uint32_t requestedIntervalMs,
632 boost::uint32_t minimumIntervalMs) {
return Error(RcfError_PingBackInterval, numberToString(requestedIntervalMs), numberToString(minimumIntervalMs) ); }
634 inline Error _RcfError_FileOpenWrite(
635 const std::string & filePath) {
return Error(RcfError_FileOpenWrite, filePath); }
637 inline Error _RcfError_CustomCertValidation(
638 const std::string & errorMsg) {
return Error(RcfError_CustomCertValidation, errorMsg); }
640 inline Error _RcfError_SupportedOnWindowsOnly(
641 const std::string & className) {
return Error(RcfError_SupportedOnWindowsOnly, className); }
643 inline Error _RcfError_NotSupportedOnWindows(
644 const std::string & className) {
return Error(RcfError_NotSupportedOnWindows, className); }
646 inline Error _RcfError_NotSupportedInThisBuild(
647 const std::string & className) {
return Error(RcfError_NotSupportedInThisBuild, className); }
654 static const int RcfSubsystem_None = 0;
655 static const int RcfSubsystem_Os = 1;
656 static const int RcfSubsystem_Zlib = 2;
657 static const int RcfSubsystem_OpenSsl = 3;
658 static const int RcfSubsystem_Asio = 4;
660 RCF_EXPORT std::string getErrorString(
int rcfError);
661 RCF_EXPORT std::string getSubSystemName(
int subSystem);
662 RCF_EXPORT std::string getOsErrorString(
int osError);
664 RCF_EXPORT
bool shouldDisconnectOnRemoteError(
const Error & err);
666 RCF_EXPORT
int getRuntimeVersionOfThisRemoteCall();
668 class RCF_EXPORT Exception :
public std::runtime_error
674 const std::string & what,
675 const std::string & context =
"");
679 const std::string & what =
"",
680 const std::string & context =
"");
685 int subSystem = RcfSubsystem_Os,
686 const std::string & what =
"",
687 const std::string & context =
"");
689 ~Exception() throw();
691 virtual std::auto_ptr<Exception> clone()
const
693 return std::auto_ptr<Exception>(
694 new Exception(*
this));
701 const char * what()
const throw();
702 const Error & getError() const;
703 int getErrorId() const;
704 std::
string getErrorString() const;
705 int getSubSystemError() const;
706 int getSubSystem() const;
707 std::
string getSubSystemName() const;
708 std::
string getContext() const;
709 std::
string getWhat() const;
711 void setContext(const std::
string &context);
712 void setWhat(const std::
string &what);
714 virtual
void throwSelf() const;
718 std::
string translate() const;
724 std::
string mContext;
729 mutable std::
string mTranslatedWhat;
732 typedef boost::shared_ptr<Exception> ExceptionPtr;
734 class RCF_EXPORT RemoteException : public Exception
741 const std::string & remoteWhat =
"",
742 const std::string & remoteContext =
"",
743 const std::string & remoteExceptionType =
"");
747 int remoteSubSystemError,
749 const std::string & remoteWhat =
"",
750 const std::string & remoteContext =
"",
751 const std::string & remoteExceptionType =
"");
753 ~RemoteException() throw();
755 const
char *what() const throw();
757 std::
string getRemoteExceptionType() const;
759 #ifdef RCF_USE_SF_SERIALIZATION
761 void serialize(SF::Archive & ar);
765 #ifdef RCF_USE_BOOST_SERIALIZATION
767 template<
typename Archive>
768 void serialize(Archive &ar,
const unsigned int)
770 int runtimeVersion = getRuntimeVersionOfThisRemoteCall();
772 bool isLoading = boost::is_base_and_derived<
773 boost::archive::detail::basic_iarchive, Archive>::value;
775 if (runtimeVersion <= 7)
777 int errorId = mError.getErrorId();
780 & boost::serialization::make_nvp(
"What", mWhat)
781 & boost::serialization::make_nvp(
"Context", mContext)
782 & boost::serialization::make_nvp(
"Error", errorId)
783 & boost::serialization::make_nvp(
"Subsystem Error", mSubSystemError)
784 & boost::serialization::make_nvp(
"Subsystem", mSubSystem)
785 & boost::serialization::make_nvp(
"Remote Exception Type", mRemoteExceptionType);
789 mError.setErrorId(errorId);
795 & boost::serialization::make_nvp(
"What", mWhat)
796 & boost::serialization::make_nvp(
"Context", mContext)
797 & boost::serialization::make_nvp(
"Error", mError)
798 & boost::serialization::make_nvp(
"Subsystem Error", mSubSystemError)
799 & boost::serialization::make_nvp(
"Subsystem", mSubSystem)
800 & boost::serialization::make_nvp(
"Remote Exception Type", mRemoteExceptionType);
806 std::auto_ptr<Exception> clone()
const;
808 void throwSelf()
const;
811 std::string mRemoteExceptionType;
814 #define RCF_DEFINE_EXCEPTION(E, PE) \
815 class E : public PE \
819 const std::string &what = "") : \
820 PE(RcfError_User, what) \
824 const std::string &what = "") : \
829 int subSystemError, \
831 const std::string &what = "") : \
832 PE(error, subSystemError, subSystem, what) \
834 std::auto_ptr<Exception> clone() const \
836 return std::auto_ptr<Exception>( \
839 void throwSelf() const \
847 RCF_DEFINE_EXCEPTION(SerializationException, Exception)
848 RCF_DEFINE_EXCEPTION(AssertionFailureException, Exception)
849 RCF_DEFINE_EXCEPTION(FilterException, Exception)
851 class RCF_EXPORT VersioningException : public RemoteException
855 boost::uint32_t runtimeVersion,
856 boost::uint32_t archiveVersion);
858 ~VersioningException() throw();
860 boost::uint32_t getRuntimeVersion() const;
861 boost::uint32_t getArchiveVersion() const;
863 std::auto_ptr<Exception> clone()
const
865 return std::auto_ptr<Exception>(
866 new VersioningException(*
this));
869 void throwSelf()
const
875 boost::uint32_t mRuntimeVersion;
876 boost::uint32_t mArchiveVersion;
879 #undef RCF_DEFINE_EXCEPTION
883 #endif // ! INCLUDE_RCF_EXCEPTION_HPP