|
|
|||
File indexing completed on 2026-01-08 10:33:34
0001 #ifndef __XRDSSIERRINFO_HH__ 0002 #define __XRDSSIERRINFO_HH__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d S s i E r r I n f o . h h */ 0006 /* */ 0007 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 #include <string> 0033 #include <cstring> 0034 0035 //----------------------------------------------------------------------------- 0036 //! The XrdSsiErrInfo object is used to hold error information for many ssi 0037 //! client-oriented requests. 0038 //----------------------------------------------------------------------------- 0039 0040 class XrdSsiErrInfo 0041 { 0042 public: 0043 0044 //----------------------------------------------------------------------------- 0045 //! Reset and clear error information. 0046 //----------------------------------------------------------------------------- 0047 0048 void Clr() {errText.clear(); errArg = errNum = 0;} 0049 0050 //----------------------------------------------------------------------------- 0051 //! Get current error information. 0052 //! 0053 //! @param eNum place where the error number is to be placed. 0054 //! 0055 //! @return The error text and the error number value. 0056 //----------------------------------------------------------------------------- 0057 0058 const 0059 std::string &Get(int &eNum) const {eNum = errNum; return errText;} 0060 0061 //----------------------------------------------------------------------------- 0062 //! Get current error text. 0063 //! 0064 //! @return The error text. 0065 //----------------------------------------------------------------------------- 0066 0067 const 0068 std::string &Get() const {return errText;} 0069 0070 //----------------------------------------------------------------------------- 0071 //! Get current error argument. 0072 //! 0073 //! @return the error argument value. 0074 //----------------------------------------------------------------------------- 0075 0076 int GetArg() const {return errArg;} 0077 0078 //----------------------------------------------------------------------------- 0079 //! Check if there is an error. 0080 //! 0081 //! @return True if an error exists and false otherwise. 0082 //----------------------------------------------------------------------------- 0083 0084 bool hasError() const {return errNum != 0;} 0085 0086 //----------------------------------------------------------------------------- 0087 //! Check if there is no error. 0088 //! 0089 //! @return True if no error exists and false otherwise. 0090 //----------------------------------------------------------------------------- 0091 0092 bool isOK() const {return errNum == 0;} 0093 0094 //----------------------------------------------------------------------------- 0095 //! Set new error information. There are two obvious variations. 0096 //! 0097 //! @param eMsg pointer to a string describing the error. If nil, the eNum 0098 //! is taken as errno and converted to corresponding description. 0099 //! @param eNum the error number associated with the error. 0100 //! @param eArg the error argument, if any (see XrdSsiService::Provision()). 0101 //----------------------------------------------------------------------------- 0102 0103 void Set(const char *eMsg=0, int eNum=0, int eArg=0) 0104 {errText = (eMsg && *eMsg ? eMsg : Errno2Text(eNum)); 0105 errNum = eNum; 0106 errArg = eArg; 0107 } 0108 0109 void Set(const std::string &eMsg, int eNum=0, int eArg=0) 0110 {errText = (eMsg.empty() ? Errno2Text(eNum) : eMsg); 0111 errNum = eNum; 0112 errArg = eArg; 0113 } 0114 0115 //------------------------------------------------------------------------------ 0116 //! Assignment operator 0117 //------------------------------------------------------------------------------ 0118 0119 XrdSsiErrInfo &operator=(XrdSsiErrInfo const &rhs) 0120 {if (&rhs != this) Set(rhs.errText, rhs.errNum, rhs.errArg); 0121 return *this; 0122 } 0123 0124 //------------------------------------------------------------------------------ 0125 //! Copy constructor 0126 //------------------------------------------------------------------------------ 0127 0128 XrdSsiErrInfo(XrdSsiErrInfo const &oP) 0129 {Set(oP.errText, oP.errNum, oP.errArg);} 0130 0131 //----------------------------------------------------------------------------- 0132 //! Constructor and Destructor 0133 //----------------------------------------------------------------------------- 0134 0135 XrdSsiErrInfo() : errNum(0), errArg(0) {} 0136 0137 ~XrdSsiErrInfo() {} 0138 0139 private: 0140 const char* Errno2Text(int ecode); 0141 0142 std::string errText; 0143 int errNum; 0144 int errArg; 0145 }; 0146 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|