File indexing completed on 2025-01-18 09:55:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef DAVIX_DAVIXSTATUSREQUEST_HPP
0023 #define DAVIX_DAVIXSTATUSREQUEST_HPP
0024
0025 #include <string>
0026 #include <utils/davix_types.hpp>
0027 #include <iostream>
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifndef __DAVIX_INSIDE__
0037 #error "Only davix.h or davix.hpp should be included."
0038 #endif
0039
0040
0041 namespace Davix {
0042
0043 class Context;
0044 class NGQRequest;
0045 struct DavixErrorInternal;
0046
0047 namespace StatusCode{
0048
0049
0050
0051
0052
0053
0054 enum Code {
0055
0056 OK = 0x000,
0057
0058
0059 PartialDone = 0x001,
0060
0061
0062 WebDavPropertiesParsingError = 0x002,
0063
0064
0065 UriParsingError = 0x003,
0066
0067
0068 SessionCreationError = 0x004,
0069
0070
0071 NameResolutionFailure= 0x005,
0072
0073
0074 ConnectionProblem = 0x006,
0075
0076
0077 RedirectionNeeded = 0x007,
0078
0079
0080 ConnectionTimeout = 0x008,
0081
0082
0083 OperationTimeout = 0x009,
0084
0085
0086 OperationNonSupported= 0x00a,
0087
0088
0089 IsNotADirectory = 0x00b,
0090
0091
0092 InvalidFileHandle = 0x00c,
0093
0094
0095 AlreadyRunning = 0x00d,
0096
0097
0098 AuthenticationError = 0x00e,
0099
0100
0101 AuthentificationError = AuthenticationError,
0102
0103
0104 LoginPasswordError = 0x00f,
0105
0106
0107 CredentialNotFound = 0x010,
0108
0109
0110 PermissionRefused = 0x011,
0111
0112
0113 FileNotFound = 0x012,
0114
0115
0116 IsADirectory = 0x013,
0117
0118
0119 SystemError = 0x014,
0120
0121
0122 FileExist = 0x015,
0123
0124
0125 InvalidArgument = 0x016,
0126
0127
0128 InvalidServerResponse = 0x017,
0129
0130
0131 SSLError = 0x018,
0132
0133
0134 CredDecryptionError = 0x019,
0135
0136
0137 Canceled = 0x020,
0138
0139
0140 DelegationError = 0x021,
0141
0142
0143
0144 RemoteError = 0x022,
0145
0146
0147 ParsingError = 0x23,
0148
0149
0150 InvalidHook = 0x24,
0151
0152
0153 TimeoutRedirectionError = 0x25,
0154
0155
0156 TooManyRedirects = 0x26,
0157
0158
0159 InsufficientStorage = 0x27,
0160
0161
0162 EnvVarNotSet = 0x28,
0163
0164
0165 UnknownError = 0x100,
0166
0167
0168 UnknowError = UnknownError
0169
0170 };
0171
0172 }
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 class DAVIX_EXPORT DavixError{
0187 public:
0188
0189
0190
0191
0192
0193
0194
0195 DavixError(const std::string & scope, StatusCode::Code errCode, const std::string & errMsg);
0196
0197
0198
0199
0200 DavixError(const DavixError & e);
0201
0202
0203
0204
0205
0206 DavixError & operator=(const DavixError & e);
0207
0208
0209
0210 virtual ~DavixError();
0211
0212
0213
0214
0215
0216
0217 DavixError* clone();
0218
0219
0220
0221 StatusCode::Code getStatus() const;
0222
0223
0224
0225 void setStatus(const StatusCode::Code);
0226
0227
0228
0229 const std::string & getErrMsg() const;
0230
0231
0232
0233 void setErrMsg(const std::string & msg);
0234
0235
0236
0237 void setErrScope(const std::string & scope);
0238
0239
0240
0241 const std::string & getErrScope() const;
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 static void setupError(DavixError** err, const std::string & scope, StatusCode::Code errCode, const std::string & errMsg);
0256
0257
0258
0259 static void clearError(DavixError** err);
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272 static void propagateError(DavixError** newErr, DavixError* oldErr);
0273
0274
0275
0276
0277
0278
0279 void swap(DavixError & err);
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291 static void propagatePrefixedError(DavixError** newErr, DavixError* oldErr, const std::string & prefix);
0292
0293 private:
0294 DavixErrorInternal * d_ptr;
0295 };
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305 class DAVIX_EXPORT DavixException : public std::exception{
0306 struct DavixExceptionIntern;
0307 public:
0308
0309 DavixException(const std::string & scope, StatusCode::Code c, const std::string & msg) throw();
0310
0311
0312 DavixException(DavixError** err);
0313
0314
0315 DavixException(const DavixException & orig) throw();
0316
0317 virtual ~DavixException() throw();
0318
0319
0320 virtual const char* scope() const throw();
0321
0322
0323 virtual StatusCode::Code code() const throw();
0324
0325
0326 virtual const char* what() const throw();
0327
0328
0329 void toDavixError(DavixError** err);
0330
0331 protected:
0332 DavixError e;
0333 DavixExceptionIntern* d_ptr;
0334 };
0335
0336
0337 void checkDavixError(DavixError** err);
0338
0339
0340 #define TRY_DAVIX try
0341 #define CATCH_DAVIX(err) catch(DavixException & e){ \
0342 e.toDavixError(err); \
0343 }catch(std::exception & e){ \
0344 DavixError::setupError(err, " ", StatusCode::SystemError, std::string("System Error ").append(e.what())); \
0345 }catch(...){ \
0346 DavixError::setupError(err, " ", StatusCode::UnknownError, std::string("Unknown Error .... report this")); \
0347 }
0348
0349
0350
0351
0352 DAVIX_EXPORT std::string davix_scope_stat_str();
0353 DAVIX_EXPORT std::string davix_scope_davOps_str();
0354 DAVIX_EXPORT std::string davix_scope_mkdir_str();
0355 DAVIX_EXPORT std::string davix_scope_rm_str();
0356 DAVIX_EXPORT std::string davix_scope_mv_str();
0357 DAVIX_EXPORT std::string davix_scope_directory_listing_str();
0358 DAVIX_EXPORT std::string davix_scope_http_request();
0359 DAVIX_EXPORT std::string davix_scope_meta();
0360 DAVIX_EXPORT std::string davix_scope_xml_parser();
0361 DAVIX_EXPORT std::string davix_scope_uri_parser();
0362 DAVIX_EXPORT std::string davix_scope_io_buff();
0363 DAVIX_EXPORT std::string davix_scope_x509cred();
0364
0365
0366
0367
0368 DAVIX_EXPORT void davix_errno_to_davix_error(int errcode, const std::string & scope, const std::string & msg, DavixError** newErr);
0369
0370 DAVIX_EXPORT void errno_to_davix_exception(int errno_code, const std::string & scope, const std::string & msg);
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397 typedef enum StatusCode::Code davix_status_t;
0398
0399
0400
0401
0402 }
0403
0404
0405 #endif