xrootd
Loading...
Searching...
No Matches
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 <cstdint>
23#include <cerrno>
24#include <sstream>
25
26namespace 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 const uint16_t suNotStarted = 5;
44
45 //----------------------------------------------------------------------------
46 // Generic errors
47 //----------------------------------------------------------------------------
48 const uint16_t errNone = 0;
49 const uint16_t errRetry = 1;
50 const uint16_t errUnknown = 2;
51 const uint16_t errInvalidOp = 3;
53 const uint16_t errFcntl = 4;
54 const uint16_t errPoll = 5;
55 const uint16_t errConfig = 6;
56 const uint16_t errInternal = 7;
57 const uint16_t errUnknownCommand = 8;
58 const uint16_t errInvalidArgs = 9;
59 const uint16_t errInProgress = 10;
60 const uint16_t errUninitialized = 11;
61 const uint16_t errOSError = 12;
62 const uint16_t errNotSupported = 13;
63 const uint16_t errDataError = 14;
64 const uint16_t errNotImplemented = 15;
65 const uint16_t errNoMoreReplicas = 16;
66 const uint16_t errPipelineFailed = 17;
67
68 //----------------------------------------------------------------------------
69 // Socket related errors
70 //----------------------------------------------------------------------------
71 const uint16_t errInvalidAddr = 101;
72 const uint16_t errSocketError = 102;
73 const uint16_t errSocketTimeout = 103;
74 const uint16_t errSocketDisconnected = 104;
75 const uint16_t errPollerError = 105;
76 const uint16_t errSocketOptError = 106;
77 const uint16_t errStreamDisconnect = 107;
78 const uint16_t errConnectionError = 108;
79 const uint16_t errInvalidSession = 109;
80 const uint16_t errTlsError = 110;
81
82 //----------------------------------------------------------------------------
83 // Post Master related errors
84 //----------------------------------------------------------------------------
85 const uint16_t errInvalidMessage = 201;
86 const uint16_t errHandShakeFailed = 202;
87 const uint16_t errLoginFailed = 203;
88 const uint16_t errAuthFailed = 204;
89 const uint16_t errQueryNotSupported = 205;
90 const uint16_t errOperationExpired = 206;
91 const uint16_t errOperationInterrupted = 207;
92 const uint16_t errThresholdExceeded = 208;
93
94 //----------------------------------------------------------------------------
95 // XRootD related errors
96 //----------------------------------------------------------------------------
97 const uint16_t errNoMoreFreeSIDs = 301;
98 const uint16_t errInvalidRedirectURL = 302;
99 const uint16_t errInvalidResponse = 303;
100 const uint16_t errNotFound = 304;
101 const uint16_t errCheckSumError = 305;
102 const uint16_t errRedirectLimit = 306;
103 const uint16_t errCorruptedHeader = 307;
104
105 const uint16_t errErrorResponse = 400;
106 const uint16_t errRedirect = 401;
107 const uint16_t errLocalError = 402;
108
109 const uint16_t errResponseNegative = 500;
110
111 //----------------------------------------------------------------------------
113 //----------------------------------------------------------------------------
114 struct Status
115 {
116 //--------------------------------------------------------------------------
118 //--------------------------------------------------------------------------
119 Status( uint16_t st = stOK, uint16_t cod = errNone, uint32_t errN = 0 ):
120 status(st), code(cod), errNo( errN ) {}
121
122 bool IsError() const { return status & stError; }
123 bool IsFatal() const { return (status&0x0002) & stFatal; }
124 bool IsOK() const { return status == stOK; }
125
126 //--------------------------------------------------------------------------
128 //--------------------------------------------------------------------------
129 int GetShellCode() const
130 {
131 if( IsOK() )
132 return 0;
133 return (code/100)+50;
134 }
135
136 inline static bool IsSocketError( uint16_t code )
137 {
138 return int( code / 100 ) == 1;
139 }
140
141 //--------------------------------------------------------------------------
143 //--------------------------------------------------------------------------
144 std::string ToString() const;
145
146 uint16_t status;
147 uint16_t code;
148 uint32_t errNo;
149 };
150}
151
152#endif // __XRD_CL_STATUS_HH__
Definition XrdClAction.hh:34
const uint16_t suPartial
Definition XrdClStatus.hh:41
const uint16_t errPoll
error while polling descriptors
Definition XrdClStatus.hh:54
const uint16_t errUnknown
Unknown error.
Definition XrdClStatus.hh:50
const uint16_t suRetry
Definition XrdClStatus.hh:40
const uint16_t errQueryNotSupported
Definition XrdClStatus.hh:89
const uint16_t errInvalidAddr
Definition XrdClStatus.hh:71
const uint16_t errStreamDisconnect
Definition XrdClStatus.hh:77
const uint16_t errRedirectLimit
Definition XrdClStatus.hh:102
const uint16_t errUninitialized
Definition XrdClStatus.hh:60
const uint16_t errSocketOptError
Definition XrdClStatus.hh:76
const uint16_t errErrorResponse
Definition XrdClStatus.hh:105
const uint16_t errTlsError
Definition XrdClStatus.hh:80
const uint16_t errOperationExpired
Definition XrdClStatus.hh:90
const uint16_t errNotImplemented
Operation is not implemented.
Definition XrdClStatus.hh:64
const uint16_t stFatal
Fatal error, it's still an error.
Definition XrdClStatus.hh:33
const uint16_t errPollerError
Definition XrdClStatus.hh:75
const uint16_t errUnknownCommand
Definition XrdClStatus.hh:57
const uint16_t stError
An error occurred that could potentially be retried.
Definition XrdClStatus.hh:32
const uint16_t errResponseNegative
Query response was negative.
Definition XrdClStatus.hh:109
const uint16_t errLoginFailed
Definition XrdClStatus.hh:87
const uint16_t errNoMoreFreeSIDs
Definition XrdClStatus.hh:97
const uint16_t errInProgress
Definition XrdClStatus.hh:59
const uint16_t errNotFound
Definition XrdClStatus.hh:100
const uint16_t errSocketTimeout
Definition XrdClStatus.hh:73
const uint16_t errDataError
data is corrupted
Definition XrdClStatus.hh:63
const uint16_t errInternal
Internal error.
Definition XrdClStatus.hh:56
const uint16_t stOK
Everything went OK.
Definition XrdClStatus.hh:31
const uint16_t errInvalidOp
Definition XrdClStatus.hh:51
const uint16_t suNotStarted
Definition XrdClStatus.hh:43
const uint16_t errHandShakeFailed
Definition XrdClStatus.hh:86
const uint16_t errConfig
System misconfigured.
Definition XrdClStatus.hh:55
const uint16_t suAlreadyDone
Definition XrdClStatus.hh:42
const uint16_t errOSError
Definition XrdClStatus.hh:61
const uint16_t errPipelineFailed
Pipeline failed and operation couldn't be executed.
Definition XrdClStatus.hh:66
const uint16_t errInvalidResponse
Definition XrdClStatus.hh:99
const uint16_t errInvalidArgs
Definition XrdClStatus.hh:58
const uint16_t errInvalidRedirectURL
Definition XrdClStatus.hh:98
const uint16_t errConnectionError
Definition XrdClStatus.hh:78
const uint16_t errNotSupported
Definition XrdClStatus.hh:62
const uint16_t errLocalError
Definition XrdClStatus.hh:107
const uint16_t errSocketError
Definition XrdClStatus.hh:72
const uint16_t errCorruptedHeader
Definition XrdClStatus.hh:103
const uint16_t errRetry
Try again for whatever reason.
Definition XrdClStatus.hh:49
const uint16_t errCheckSumError
Definition XrdClStatus.hh:101
const uint16_t suDone
Definition XrdClStatus.hh:38
const uint16_t errThresholdExceeded
Definition XrdClStatus.hh:92
const uint16_t errOperationInterrupted
Definition XrdClStatus.hh:91
const uint16_t suContinue
Definition XrdClStatus.hh:39
const uint16_t errFcntl
failed manipulate file descriptor
Definition XrdClStatus.hh:53
const uint16_t errNoMoreReplicas
No more replicas to try.
Definition XrdClStatus.hh:65
const uint16_t errNone
No error.
Definition XrdClStatus.hh:48
const uint16_t errInvalidSession
Definition XrdClStatus.hh:79
const uint16_t errRedirect
Definition XrdClStatus.hh:106
const uint16_t errSocketDisconnected
Definition XrdClStatus.hh:74
const uint16_t errAuthFailed
Definition XrdClStatus.hh:88
const uint16_t errInvalidMessage
Definition XrdClStatus.hh:85
Procedure execution status.
Definition XrdClStatus.hh:115
Status(uint16_t st=stOK, uint16_t cod=errNone, uint32_t errN=0)
Constructor.
Definition XrdClStatus.hh:119
uint16_t code
Error type, or additional hints on what to do.
Definition XrdClStatus.hh:147
uint16_t status
Status of the execution.
Definition XrdClStatus.hh:146
bool IsOK() const
We're fine.
Definition XrdClStatus.hh:124
bool IsFatal() const
Fatal error.
Definition XrdClStatus.hh:123
std::string ToString() const
Create a string representation.
bool IsError() const
Error.
Definition XrdClStatus.hh:122
static bool IsSocketError(uint16_t code)
Definition XrdClStatus.hh:136
uint32_t errNo
Errno, if any.
Definition XrdClStatus.hh:148
int GetShellCode() const
Get the status code that may be returned to the shell.
Definition XrdClStatus.hh:129