diff --git a/tapeserver/castor/exception/SErrnum.cpp b/tapeserver/castor/exception/SErrnum.cpp deleted file mode 100644 index a99bc437e5e0c67a515a2bceda4b077728460a34..0000000000000000000000000000000000000000 --- a/tapeserver/castor/exception/SErrnum.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/****************************************************************************** - * - * This file is part of the Castor project. - * See http://castor.web.cern.ch/castor - * - * Copyright (C) 2003 CERN - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * - * - * - * @author Castor Dev team, castor-dev@cern.ch - *****************************************************************************/ - -#include "castor/exception/SErrnum.hpp" - -#include <errno.h> -#include <string.h> - -using namespace castor::exception; - -SErrnum::SErrnum(std::string what):Exception("") { - m_serrnum = serrno; - m_errnum = errno; - SErrnumConstructorBottomHalf(what); -} - -SErrnum::SErrnum(int err, std::string what):Exception("") { - m_serrnum = err; - m_errnum = errno; - SErrnumConstructorBottomHalf(what); -} - -void SErrnum::SErrnumConstructorBottomHalf(const std::string & what) { - char buf[100]; - - // Castor-style error reporting is not for the faint of the heart. - // If we get serrno = 0, we should rely on the errnum instead - if(m_serrnum) { - // Normal case, serrnum is not zero. - if(sstrerror_r(m_serrnum, buf, sizeof(buf))) { - // sstrerror_r() failed - const int new_errno = errno; - std::stringstream w; - w << "SErrno=" << m_serrnum << ". In addition, failed to read the corresponding error string (sstrerror_r gave errno=" - << new_errno << ")"; - m_sstrerror = w.str(); - } else { - // sstrerror_r() succeeded - m_sstrerror = buf; - } - std::stringstream w2; - if (what.size()) - w2 << what << " "; - w2 << "SErrno=" << m_serrnum << ": " << m_sstrerror; - getMessage().str(w2.str()); - } else { - // degraded case, serrnum is indeed 0, we fall back on the normal error reporting. - std::stringstream w; - w << "Serrno=0. Falling back to errno=" << m_errnum; - char buf[100]; - - if(sstrerror_r(m_errnum, buf, sizeof(buf))) { - // sstrerror_r() failed - const int new_errno = errno; - w << ". In addition, failed to read the corresponding error string (sstrerror_r gave errno=" - << new_errno << ")"; - } else { - // sstrerror_r() succeeded - w << ". "<< buf; - } - std::stringstream w2; - if (what.size()) - w2 << what << " "; - w2 << w.str(); - getMessage().str(w2.str()); - } -} - -void SErrnum::throwOnReturnedErrno (int err, std::string context) { - if (err) throw SErrnum(err, context); -} - -void SErrnum::throwOnNonZero(int status, std::string context) { - if (status) throw SErrnum(context); -} - -void SErrnum::throwOnZero(int status, std::string context) { - if (!status) throw SErrnum(context); -} - -void SErrnum::throwOnNull(void * f, std::string context) { - if (NULL == f) throw SErrnum(context); -} - -void SErrnum::throwOnNegative(int ret, std::string context) { - if (ret < 0) throw SErrnum(context); -} - -void SErrnum::throwOnMinusOne(int ret, std::string context) { - if (-1 == ret) throw SErrnum(context); -} diff --git a/tapeserver/castor/exception/SErrnum.hpp b/tapeserver/castor/exception/SErrnum.hpp deleted file mode 100644 index 432d6b23a1daa8ac0ccaf8902cf6c1eed2f510fc..0000000000000000000000000000000000000000 --- a/tapeserver/castor/exception/SErrnum.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** - * - * This file is part of the Castor project. - * See http://castor.web.cern.ch/castor - * - * Copyright (C) 2003 CERN - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * - * - * - * @author Castor Dev team, castor-dev@cern.ch - *****************************************************************************/ - -#pragma once - -#include "common/exception/Exception.hpp" - -namespace castor { -namespace exception { - class SErrnum: public cta::exception::Exception { - public: - SErrnum(std::string what = ""); - SErrnum (int err, std::string what = ""); - virtual ~SErrnum() throw() {}; - int ErrorNumber() { return m_serrnum; } - std::string strError() { return m_sstrerror; } - static void throwOnReturnedErrno(int err, std::string context = ""); - static void throwOnNonZero(int status, std::string context = ""); - static void throwOnZero(int status, std::string context = ""); - static void throwOnNull(void * f, std::string context = ""); - static void throwOnNegative(int ret, std::string context = ""); - static void throwOnMinusOne(int ret, std::string context = ""); - protected: - void SErrnumConstructorBottomHalf(const std::string & what); - int m_serrnum; - int m_errnum; - std::string m_sstrerror; - }; -} -} diff --git a/tapeserver/castor/tape/tapeserver/file/DiskFile.cpp b/tapeserver/castor/tape/tapeserver/file/DiskFile.cpp index 9a180a61816207a06010fa4c992d36b969c997ae..febbe163ae97720d97b32a6b6bfb7d91fc87ee22 100644 --- a/tapeserver/castor/tape/tapeserver/file/DiskFile.cpp +++ b/tapeserver/castor/tape/tapeserver/file/DiskFile.cpp @@ -26,7 +26,6 @@ #include "castor/tape/tapeserver/file/DiskFile.hpp" #include "castor/tape/tapeserver/file/DiskFileImplementations.hpp" #include "castor/exception/Errnum.hpp" -#include "castor/exception/SErrnum.hpp" #include "castor/server/MutexLocker.hpp" #include <xrootd/XrdCl/XrdClFile.hh> #include <uuid/uuid.h> diff --git a/tapeserver/castor/tape/tapeserver/file/File.cpp b/tapeserver/castor/tape/tapeserver/file/File.cpp index c5d7eab9d8e37b9d5af9405ef16e41338d85a70e..b226029b524299905688aa2eeb92aa7db4867c9b 100644 --- a/tapeserver/castor/tape/tapeserver/file/File.cpp +++ b/tapeserver/castor/tape/tapeserver/file/File.cpp @@ -23,7 +23,6 @@ #include "castor/tape/tapeserver/file/File.hpp" #include "castor/exception/Errnum.hpp" -#include "castor/exception/SErrnum.hpp" #include "common/exception/InvalidArgument.hpp" #include <sstream> #include <iomanip>