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 
66  //----------------------------------------------------------------------------
67  // Socket related errors
68  //----------------------------------------------------------------------------
69  const uint16_t errInvalidAddr = 101;
70  const uint16_t errSocketError = 102;
71  const uint16_t errSocketTimeout = 103;
72  const uint16_t errSocketDisconnected = 104;
73  const uint16_t errPollerError = 105;
74  const uint16_t errSocketOptError = 106;
75  const uint16_t errStreamDisconnect = 107;
76  const uint16_t errConnectionError = 108;
77  const uint16_t errInvalidSession = 109;
78 
79  //----------------------------------------------------------------------------
80  // Post Master related errors
81  //----------------------------------------------------------------------------
82  const uint16_t errInvalidMessage = 201;
83  const uint16_t errHandShakeFailed = 202;
84  const uint16_t errLoginFailed = 203;
85  const uint16_t errAuthFailed = 204;
86  const uint16_t errQueryNotSupported = 205;
87  const uint16_t errOperationExpired = 206;
88 
89  //----------------------------------------------------------------------------
90  // XRootD related errors
91  //----------------------------------------------------------------------------
92  const uint16_t errNoMoreFreeSIDs = 301;
93  const uint16_t errInvalidRedirectURL = 302;
94  const uint16_t errInvalidResponse = 303;
95  const uint16_t errNotFound = 304;
96  const uint16_t errCheckSumError = 305;
97  const uint16_t errRedirectLimit = 306;
98 
99  const uint16_t errErrorResponse = 400;
100  const uint16_t errRedirect = 401;
101 
102  const uint16_t errResponseNegative = 500;
103 
104  //----------------------------------------------------------------------------
106  //----------------------------------------------------------------------------
107  struct Status
108  {
109  //--------------------------------------------------------------------------
111  //--------------------------------------------------------------------------
112  Status( uint16_t st = stOK, uint16_t cod = errNone, uint32_t errN = 0 ):
113  status(st), code(cod), errNo( errN ) {}
114 
115  bool IsError() const { return status & stError; }
116  bool IsFatal() const { return (status&0x0002) & stFatal; }
117  bool IsOK() const { return status == stOK; }
118 
119  //--------------------------------------------------------------------------
121  //--------------------------------------------------------------------------
122  int GetShellCode() const
123  {
124  if( IsOK() )
125  return 0;
126  return (code/100)+50;
127  }
128 
129  //--------------------------------------------------------------------------
131  //--------------------------------------------------------------------------
132  std::string ToString() const;
133 
134  uint16_t status;
135  uint16_t code;
136  uint32_t errNo;
137  };
138 }
139 
140 #endif // __XRD_CL_STATUS_HH__
const uint16_t errUnknownCommand
Definition: XrdClStatus.hh:56
const uint16_t errInvalidResponse
Definition: XrdClStatus.hh:94
const uint16_t errNoMoreFreeSIDs
Definition: XrdClStatus.hh:92
const uint16_t errSocketTimeout
Definition: XrdClStatus.hh:71
const uint16_t stOK
Everything went OK.
Definition: XrdClStatus.hh:31
bool IsError() const
Error.
Definition: XrdClStatus.hh:115
const uint16_t errQueryNotSupported
Definition: XrdClStatus.hh:86
const uint16_t errAuthFailed
Definition: XrdClStatus.hh:85
const uint16_t errInvalidArgs
Definition: XrdClStatus.hh:57
const uint16_t errConfig
System misconfigured.
Definition: XrdClStatus.hh:54
const uint16_t errFcntl
failed manipulate file descriptor
Definition: XrdClStatus.hh:52
const uint16_t errSocketError
Definition: XrdClStatus.hh:70
const uint16_t errNone
No error.
Definition: XrdClStatus.hh:47
const uint16_t errInProgress
Definition: XrdClStatus.hh:58
const uint16_t errUnknown
Unknown error.
Definition: XrdClStatus.hh:49
const uint16_t errErrorResponse
Definition: XrdClStatus.hh:99
const uint16_t errRedirectLimit
Definition: XrdClStatus.hh:97
const uint16_t suDone
Definition: XrdClStatus.hh:38
const uint16_t errSocketOptError
Definition: XrdClStatus.hh:74
uint16_t code
Error type, or additional hints on what to do.
Definition: XrdClStatus.hh:135
const uint16_t suPartial
Definition: XrdClStatus.hh:41
const uint16_t errSocketDisconnected
Definition: XrdClStatus.hh:72
const uint16_t errNotSupported
Definition: XrdClStatus.hh:61
const uint16_t errOSError
Definition: XrdClStatus.hh:60
Procedure execution status.
Definition: XrdClStatus.hh:107
uint16_t status
Status of the execution.
Definition: XrdClStatus.hh:134
const uint16_t errUninitialized
Definition: XrdClStatus.hh:59
const uint16_t errPoll
error while polling descriptors
Definition: XrdClStatus.hh:53
bool IsFatal() const
Fatal error.
Definition: XrdClStatus.hh:116
const uint16_t errCheckSumError
Definition: XrdClStatus.hh:96
const uint16_t errNotImplemented
Operation is not implemented.
Definition: XrdClStatus.hh:63
const uint16_t errNoMoreReplicas
No more replicas to try.
Definition: XrdClStatus.hh:64
const uint16_t errStreamDisconnect
Definition: XrdClStatus.hh:75
const uint16_t suAlreadyDone
Definition: XrdClStatus.hh:42
const uint16_t stFatal
Fatal error, it&#39;s still an error.
Definition: XrdClStatus.hh:33
const uint16_t errInvalidMessage
Definition: XrdClStatus.hh:82
const uint16_t errHandShakeFailed
Definition: XrdClStatus.hh:83
const uint16_t errDataError
data is corrupted
Definition: XrdClStatus.hh:62
std::string ToString() const
Create a string representation.
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errNotFound
Definition: XrdClStatus.hh:95
const uint16_t errOperationExpired
Definition: XrdClStatus.hh:87
const uint16_t errRedirect
Definition: XrdClStatus.hh:100
const uint16_t errPollerError
Definition: XrdClStatus.hh:73
Status(uint16_t st=stOK, uint16_t cod=errNone, uint32_t errN=0)
Constructor.
Definition: XrdClStatus.hh:112
const uint16_t suContinue
Definition: XrdClStatus.hh:39
const uint16_t errLoginFailed
Definition: XrdClStatus.hh:84
uint32_t errNo
Errno, if any.
Definition: XrdClStatus.hh:136
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:55
const uint16_t errConnectionError
Definition: XrdClStatus.hh:76
const uint16_t errInvalidAddr
Definition: XrdClStatus.hh:69
const uint16_t suRetry
Definition: XrdClStatus.hh:40
bool IsOK() const
We&#39;re fine.
Definition: XrdClStatus.hh:117
int GetShellCode() const
Get the status code that may be returned to the shell.
Definition: XrdClStatus.hh:122
const uint16_t errRetry
Try again for whatever reason.
Definition: XrdClStatus.hh:48
const uint16_t errInvalidOp
Definition: XrdClStatus.hh:50
const uint16_t errResponseNegative
Query response was negative.
Definition: XrdClStatus.hh:102
const uint16_t errInvalidSession
Definition: XrdClStatus.hh:77
const uint16_t errInvalidRedirectURL
Definition: XrdClStatus.hh:93