Commit c25d8608 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Added the retryable error exception and added the catching of different...

Added the retryable error exception and added the catching of different backend exceptions in the frontend
parent 1b4e77f1
......@@ -66,17 +66,13 @@ set (COMMON_LIB_SRC_FILES
admin/AdminHost.cpp
admin/AdminUser.cpp
archiveRoutes/ArchiveRoute.cpp
# archiveNS/ArchiveFile.cpp
# archiveNS/ArchiveFileStatus.cpp
# archiveNS/StorageClass.cpp
# archiveNS/Tape.cpp
# archiveNS/TapeFileLocation.cpp
checksum/Checksum.cpp
exception/Backtrace.cpp
exception/Errnum.cpp
exception/Exception.cpp
exception/UserError.cpp
exception/NonRetryableError.cpp
exception/RetryableError.cpp
exception/UserError.cpp
log/DummyLogger.cpp
log/LogContext.cpp
log/Logger.cpp
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "common/exception/RetryableError.hpp"
namespace cta {
namespace exception {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
RetryableError::RetryableError(const std::string &context, const bool embedBacktrace):
Exception(context, embedBacktrace) {
}
} // namespace exception
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common/exception/Exception.hpp"
namespace cta {
namespace exception {
/**
* An exception class representing an application error that should not be retried.
*/
class RetryableError: public exception::Exception {
public:
/**
* Constructor.
*
* @param context optional context string added to the message
* at initialisation time.
* @param embedBacktrace whether to embed a backtrace of where the
* exception was throw in the message
*/
RetryableError(const std::string &context = "", const bool embedBacktrace = true);
}; // class RetryableError
} // namespace exception
} // namespace cta
......@@ -24,6 +24,9 @@
#include "catalogue/ArchiveFileSearchCriteria.hpp"
#include "common/Configuration.hpp"
#include "common/utils/utils.hpp"
#include "common/exception/UserError.hpp"
#include "common/exception/NonRetryableError.hpp"
#include "common/exception/RetryableError.hpp"
#include <cryptopp/base64.h>
#include <cryptopp/osrng.h>
......@@ -194,6 +197,12 @@ int XrdCtaFile::open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t c
return logRequestAndSetCmdlineResult(cta::common::dataStructures::FrontendReturnCode::userErrorNoRetry, getGenericHelp(m_requestTokens.at(0)));
}
return dispatchCommand();
} catch (cta::exception::UserError &ex) {
return logRequestAndSetCmdlineResult(cta::common::dataStructures::FrontendReturnCode::userErrorNoRetry, ex.getMessageValue()+"\n");
} catch (cta::exception::NonRetryableError &ex) {
return logRequestAndSetCmdlineResult(cta::common::dataStructures::FrontendReturnCode::ctaErrorNoRetry, ex.getMessageValue()+"\n");
} catch (cta::exception::RetryableError &ex) {
return logRequestAndSetCmdlineResult(cta::common::dataStructures::FrontendReturnCode::ctaErrorRetry, ex.getMessageValue()+"\n");
} catch (cta::exception::Exception &ex) {
return logRequestAndSetCmdlineResult(cta::common::dataStructures::FrontendReturnCode::ctaErrorNoRetry, ex.getMessageValue()+"\n");
} catch (std::exception &ex) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment