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