xrootd
XrdClStatus.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_STATUS_HH__
20 #define __XRD_CL_STATUS_HH__
21 
22 #include <stdint.h>
23 #include <errno.h>
24 #include <sstream>
25 
26 namespace XrdCl
27 {
28  //----------------------------------------------------------------------------
29  // Constants
30  //----------------------------------------------------------------------------
31  const uint16_t stOK = 0x0000;
32  const uint16_t stError = 0x0001;
33  const uint16_t stFatal = 0x0003;
34 
35  //----------------------------------------------------------------------------
36  // Additional info for the stOK status
37  //----------------------------------------------------------------------------
38  const uint16_t suDone = 0;
39  const uint16_t suContinue = 1;
40  const uint16_t suRetry = 2;
41  const uint16_t suPartial = 3;
42  const uint16_t suAlreadyDone = 4;
43 
44  //----------------------------------------------------------------------------
45  // Generic errors
46  //----------------------------------------------------------------------------
47  const uint16_t errNone = 0;
48  const uint16_t errRetry = 1;
49  const uint16_t errUnknown = 2;
50  const uint16_t errInvalidOp = 3;
51  const uint16_t errFcntl = 4;
53  const uint16_t errPoll = 5;
54  const uint16_t errConfig = 6;
55  const uint16_t errInternal = 7;
56  const uint16_t errUnknownCommand = 8;
57  const uint16_t errInvalidArgs = 9;
58  const uint16_t errInProgress = 10;
59  const uint16_t errUninitialized = 11;
60  const uint16_t errOSError = 12;
61  const uint16_t errNotSupported = 13;
62  const uint16_t errDataError = 14;
63  const uint16_t errNotImplemented = 15;
64  const uint16_t errNoMoreReplicas = 16;
65  const uint16_t errPipelineFailed = 17;
66 
67  //----------------------------------------------------------------------------
68  // Socket related errors
69  //----------------------------------------------------------------------------
70  const uint16_t errInvalidAddr = 101;
71  const uint16_t errSocketError = 102;
72  const uint16_t errSocketTimeout = 103;
73  const uint16_t errSocketDisconnected = 104;
74  const uint16_t errPollerError = 105;
75  const uint16_t errSocketOptError = 106;
76  const uint16_t errStreamDisconnect = 107;
77  const uint16_t errConnectionError = 108;
78  const uint16_t errInvalidSession = 109;
79  const uint16_t errTlsError = 110;
80 
81  //----------------------------------------------------------------------------
82  // Post Master related errors
83  //----------------------------------------------------------------------------
84  const uint16_t errInvalidMessage = 201;
85  const uint16_t errHandShakeFailed = 202;
86  const uint16_t errLoginFailed = 203;
87  const uint16_t errAuthFailed = 204;
88  const uint16_t errQueryNotSupported = 205;
89  const uint16_t errOperationExpired = 206;
90  const uint16_t errOperationInterrupted = 207;
91 
92  //----------------------------------------------------------------------------
93  // XRootD related errors
94  //----------------------------------------------------------------------------
95  const uint16_t errNoMoreFreeSIDs = 301;
96  const uint16_t errInvalidRedirectURL = 302;
97  const uint16_t errInvalidResponse = 303;
98  const uint16_t errNotFound = 304;
99  const uint16_t errCheckSumError = 305;
100  const uint16_t errRedirectLimit = 306;
101 
102  const uint16_t errErrorResponse = 400;
103  const uint16_t errRedirect = 401;
104 
105  const uint16_t errResponseNegative = 500;
106 
107  //----------------------------------------------------------------------------
109  //----------------------------------------------------------------------------
110  struct Status
111  {
112  //--------------------------------------------------------------------------
114  //--------------------------------------------------------------------------
115  Status( uint16_t st = stOK, uint16_t cod = errNone, uint32_t errN = 0 ):
116  status(st), code(cod), errNo( errN ) {}
117 
118  bool IsError() const { return status & stError; }
119  bool IsFatal() const { return (status&0x0002) & stFatal; }
120  bool IsOK() const { return status == stOK; }
121 
122  //--------------------------------------------------------------------------
124  //--------------------------------------------------------------------------
125  int GetShellCode() const
126  {
127  if( IsOK() )
128  return 0;
129  return (code/100)+50;
130  }
131 
132  //--------------------------------------------------------------------------
134  //--------------------------------------------------------------------------
135  std::string ToString() const;
136 
137  uint16_t status;
138  uint16_t code;
139  uint32_t errNo;
140  };
141 }
142 
143 #endif // __XRD_CL_STATUS_HH__
XrdCl::Status::code
uint16_t code
Error type, or additional hints on what to do.
Definition: XrdClStatus.hh:138
XrdCl::errOperationExpired
const uint16_t errOperationExpired
Definition: XrdClStatus.hh:89
XrdCl::stOK
const uint16_t stOK
Everything went OK.
Definition: XrdClStatus.hh:31
XrdCl::errInvalidAddr
const uint16_t errInvalidAddr
Definition: XrdClStatus.hh:70
XrdCl::Status::ToString
std::string ToString() const
Create a string representation.
XrdCl::Status::IsError
bool IsError() const
Error.
Definition: XrdClStatus.hh:118
XrdCl::errDataError
const uint16_t errDataError
data is corrupted
Definition: XrdClStatus.hh:62
XrdCl::suContinue
const uint16_t suContinue
Definition: XrdClStatus.hh:39
XrdCl::errTlsError
const uint16_t errTlsError
Definition: XrdClStatus.hh:79
XrdCl::errRedirect
const uint16_t errRedirect
Definition: XrdClStatus.hh:103
XrdCl::stFatal
const uint16_t stFatal
Fatal error, it's still an error.
Definition: XrdClStatus.hh:33
XrdCl::errSocketTimeout
const uint16_t errSocketTimeout
Definition: XrdClStatus.hh:72
XrdCl::errNone
const uint16_t errNone
No error.
Definition: XrdClStatus.hh:47
XrdCl::suDone
const uint16_t suDone
Definition: XrdClStatus.hh:38
XrdCl::errUninitialized
const uint16_t errUninitialized
Definition: XrdClStatus.hh:59
XrdCl::errInternal
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:55
XrdCl::Status::GetShellCode
int GetShellCode() const
Get the status code that may be returned to the shell.
Definition: XrdClStatus.hh:125
XrdCl::errSocketOptError
const uint16_t errSocketOptError
Definition: XrdClStatus.hh:75
XrdCl::errUnknownCommand
const uint16_t errUnknownCommand
Definition: XrdClStatus.hh:56
XrdCl::errNotImplemented
const uint16_t errNotImplemented
Operation is not implemented.
Definition: XrdClStatus.hh:63
XrdCl::errSocketError
const uint16_t errSocketError
Definition: XrdClStatus.hh:71
XrdCl::Status::status
uint16_t status
Status of the execution.
Definition: XrdClStatus.hh:137
XrdCl::Status::errNo
uint32_t errNo
Errno, if any.
Definition: XrdClStatus.hh:139
XrdCl::Status::Status
Status(uint16_t st=stOK, uint16_t cod=errNone, uint32_t errN=0)
Constructor.
Definition: XrdClStatus.hh:115
XrdCl::errFcntl
const uint16_t errFcntl
failed manipulate file descriptor
Definition: XrdClStatus.hh:52
XrdCl::errOSError
const uint16_t errOSError
Definition: XrdClStatus.hh:60
XrdCl::errQueryNotSupported
const uint16_t errQueryNotSupported
Definition: XrdClStatus.hh:88
XrdCl::errOperationInterrupted
const uint16_t errOperationInterrupted
Definition: XrdClStatus.hh:90
XrdCl::errAuthFailed
const uint16_t errAuthFailed
Definition: XrdClStatus.hh:87
XrdCl::errResponseNegative
const uint16_t errResponseNegative
Query response was negative.
Definition: XrdClStatus.hh:105
XrdCl::errErrorResponse
const uint16_t errErrorResponse
Definition: XrdClStatus.hh:102
XrdCl::errInvalidMessage
const uint16_t errInvalidMessage
Definition: XrdClStatus.hh:84
XrdCl::errRedirectLimit
const uint16_t errRedirectLimit
Definition: XrdClStatus.hh:100
XrdCl::errInvalidResponse
const uint16_t errInvalidResponse
Definition: XrdClStatus.hh:97
XrdCl::errInvalidSession
const uint16_t errInvalidSession
Definition: XrdClStatus.hh:78
XrdCl::errRetry
const uint16_t errRetry
Try again for whatever reason.
Definition: XrdClStatus.hh:48
XrdCl::Status::IsFatal
bool IsFatal() const
Fatal error.
Definition: XrdClStatus.hh:119
XrdCl::Status::IsOK
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:120
XrdCl::errInvalidRedirectURL
const uint16_t errInvalidRedirectURL
Definition: XrdClStatus.hh:96
XrdCl::errUnknown
const uint16_t errUnknown
Unknown error.
Definition: XrdClStatus.hh:49
XrdCl::errConfig
const uint16_t errConfig
System misconfigured.
Definition: XrdClStatus.hh:54
XrdCl::suRetry
const uint16_t suRetry
Definition: XrdClStatus.hh:40
XrdCl::errNoMoreFreeSIDs
const uint16_t errNoMoreFreeSIDs
Definition: XrdClStatus.hh:95
XrdCl
Definition: XrdClAnyObject.hh:26
XrdCl::errPoll
const uint16_t errPoll
error while polling descriptors
Definition: XrdClStatus.hh:53
XrdCl::errPollerError
const uint16_t errPollerError
Definition: XrdClStatus.hh:74
XrdCl::errHandShakeFailed
const uint16_t errHandShakeFailed
Definition: XrdClStatus.hh:85
XrdCl::suPartial
const uint16_t suPartial
Definition: XrdClStatus.hh:41
XrdCl::errNotSupported
const uint16_t errNotSupported
Definition: XrdClStatus.hh:61
XrdCl::errSocketDisconnected
const uint16_t errSocketDisconnected
Definition: XrdClStatus.hh:73
XrdCl::errNoMoreReplicas
const uint16_t errNoMoreReplicas
No more replicas to try.
Definition: XrdClStatus.hh:64
XrdCl::errInProgress
const uint16_t errInProgress
Definition: XrdClStatus.hh:58
XrdCl::stError
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
XrdCl::errLoginFailed
const uint16_t errLoginFailed
Definition: XrdClStatus.hh:86
XrdCl::Status
Procedure execution status.
Definition: XrdClStatus.hh:111
XrdCl::errConnectionError
const uint16_t errConnectionError
Definition: XrdClStatus.hh:77
XrdCl::errNotFound
const uint16_t errNotFound
Definition: XrdClStatus.hh:98
XrdCl::errInvalidOp
const uint16_t errInvalidOp
Definition: XrdClStatus.hh:50
XrdCl::errCheckSumError
const uint16_t errCheckSumError
Definition: XrdClStatus.hh:99
XrdCl::errPipelineFailed
const uint16_t errPipelineFailed
Pipeline failed and operation couldn't be executed.
Definition: XrdClStatus.hh:65
XrdCl::errStreamDisconnect
const uint16_t errStreamDisconnect
Definition: XrdClStatus.hh:76
XrdCl::suAlreadyDone
const uint16_t suAlreadyDone
Definition: XrdClStatus.hh:42
XrdCl::errInvalidArgs
const uint16_t errInvalidArgs
Definition: XrdClStatus.hh:57