Commit c8289901 authored by David COME's avatar David COME
Browse files

Removed the castor::tape::Exception class

parent 9744b1ea
......@@ -25,7 +25,7 @@
#include "castor/server/BlockingQueue.hpp"
#include "castor/tape/tapeserver/daemon/MemBlock.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
namespace castor {
......
......@@ -34,7 +34,7 @@
#include "castor/tape/tapeserver/daemon/TapeReadSingleThread.hpp"
#include "castor/tape/tapeserver/daemon/TapeServerReporter.hpp"
#include "castor/tape/tapeserver/drive/DriveInterface.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/tape/tapeserver/SCSI/Device.hpp"
#include "castor/tape/utils/utils.hpp"
#include "h/log.h"
......
......@@ -77,7 +77,7 @@ void DiskReadTask::execute(log::LogContext& lc) {
tape::diskFile::ReadFile sourceFile(m_migratedFile->path());
if(migratingFileSize != sourceFile.size()){
throw castor::tape::Exception("Mismtach between size given by the client "
throw castor::exception::Exception("Mismtach between size given by the client "
"and the real one");
}
......@@ -108,7 +108,7 @@ void DiskReadTask::execute(log::LogContext& lc) {
if(mb->m_payload.size() != mb->m_payload.totalCapacity() && migratingFileSize>0){
std::string erroMsg = "Error while reading a file. Did not read at full capacity but the file is not fully read";
mb->markAsFailed(erroMsg,SEINTERNAL);
throw castor::tape::Exception(erroMsg);
throw castor::exception::Exception(erroMsg);
}
m_stats.checkingErrorTime += localTime.secs(utils::Timer::resetCounter);
......@@ -122,7 +122,7 @@ void DiskReadTask::execute(log::LogContext& lc) {
"Do nothing except circulating blocks");
circulateAllBlocks(blockId);
}
catch(const castor::tape::Exception& e){
catch(const castor::exception::Exception& e){
//signal to all others task that this session is screwed
m_errorFlag.set();
......
......@@ -120,7 +120,7 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,log::LogContext& lc) {
// DiskWriteTask::getFreeBlock
//------------------------------------------------------------------------------
MemBlock *DiskWriteTask::getFreeBlock() {
throw castor::tape::Exception("DiskWriteTask::getFreeBlock should mot be called");
throw castor::exception::Exception("DiskWriteTask::getFreeBlock should mot be called");
}
//------------------------------------------------------------------------------
......
......@@ -87,7 +87,7 @@ void DiskWriteThreadPool::waitThreads() {
void DiskWriteThreadPool::push(DiskWriteTask *t) {
{
if(NULL==t){
throw castor::tape::Exception("NULL task should not been directly pushed into DiskWriteThreadPool");
throw castor::exception::Exception("NULL task should not been directly pushed into DiskWriteThreadPool");
}
}
castor::server::MutexLocker ml(&m_pusherProtection);
......
......@@ -26,7 +26,7 @@
#include "castor/legacymsg/MessageHeader.hpp"
#include "castor/log/LogContext.hpp"
#include "castor/tape/tapeserver/daemon/LabelSession.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/tape/utils/utils.hpp"
#include "castor/System.hpp"
#include "castor/tape/tapeserver/drive/DriveInterface.hpp"
......
......@@ -23,7 +23,7 @@
#pragma once
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/tape/tapeserver/file/File.hpp"
#include <memory>
#include "castor/tape/tapeserver/daemon/Payload.hpp"
......
......@@ -29,7 +29,7 @@
#include <cstdio>
namespace{
struct failedMigrationRecallResult : public castor::tape::Exception{
struct failedMigrationRecallResult : public castor::exception::Exception{
failedMigrationRecallResult(const std::string& s): Exception(s){}
};
}
......@@ -126,7 +126,7 @@ void MigrationReportPacker::ReportFlush::execute(MigrationReportPacker& _this){
try{
_this.m_client.reportMigrationResults(*(_this.m_listReports),chrono);
}
catch(const castor::tape::Exception& e){
catch(const castor::exception::Exception& e){
LogContext::ScopedParam sp[]={
LogContext::ScopedParam(_this.m_lc, Param("exceptionCode",e.code())),
LogContext::ScopedParam(_this.m_lc, Param("exceptionMessageValue", e.getMessageValue())),
......@@ -229,7 +229,7 @@ void MigrationReportPacker::WorkerThread::run(){
}
}
}
catch(const castor::tape::Exception& e){
catch(const castor::exception::Exception& e){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
m_parent.logRequestReport(chrono,"tried to report endOfSession(WithError) and got an exception, cant do much more",LOG_ERR);
......
......@@ -29,7 +29,7 @@
#include <signal.h>
namespace{
struct failedReportRecallResult : public castor::tape::Exception{
struct failedReportRecallResult : public castor::exception::Exception{
failedReportRecallResult(const std::string& s): Exception(s){}
};
}
......@@ -131,7 +131,7 @@ void RecallReportPacker::flush(){
logReport(m_listReports->failedRecalls(),"Reported failed recall to client");
logReport(m_listReports->successfulRecalls(),"Reported successful recall to client");
}
catch(const castor::tape::Exception& e){
catch(const castor::exception::Exception& e){
LogContext::ScopedParam s(m_lc, Param("exceptionCode",e.code()));
LogContext::ScopedParam ss(m_lc, Param("exceptionMessageValue", e.getMessageValue()));
LogContext::ScopedParam sss(m_lc, Param("exceptionWhat",e.what()));
......@@ -285,7 +285,7 @@ void RecallReportPacker::WorkerThread::run(){
}
}
}
catch(const castor::tape::Exception& e){
catch(const castor::exception::Exception& e){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
m_parent.logRequestReport(chrono,"tried to report endOfSession(WithError) and got an exception, cant do much more",LOG_ERR);
......
......@@ -164,7 +164,7 @@ TEST(castor_tape_tapeserver_daemon, RecallReportPackerFaillure) {
MockClient client;
::testing::InSequence dummy;
EXPECT_CALL(client, reportRecallResults(_,_)).WillRepeatedly(Throw(castor::tape::Exception("")));
EXPECT_CALL(client, reportRecallResults(_,_)).WillRepeatedly(Throw(castor::exception::Exception("")));
EXPECT_CALL(client, reportEndOfSessionWithError(_,SEINTERNAL,_)).Times(1);
castor::log::StringLogger log("castor_tape_tapeserver_RecallReportPackerBadBadEnd");
......
......@@ -27,7 +27,7 @@
#include "castor/tape/tapeserver/daemon/DataPipeline.hpp"
#include "castor/tape/tapeserver/daemon/RecallMemoryManager.hpp"
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/tape/tapeserver/daemon/AutoReleaseBlock.hpp"
#include "castor/tape/tapeserver/daemon/TaskWatchDog.hpp"
#include "castor/tape/tapeserver/daemon/TapeSessionStats.hpp"
......
......@@ -29,7 +29,7 @@
#include "castor/tape/tapeserver/utils/suppressUnusedVariable.hpp"
#include "castor/tape/tapeserver/file/File.hpp"
#include "castor/tape/tapeserver/daemon/AutoReleaseBlock.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/tape/tapeserver/daemon/MigrationReportPacker.hpp"
#include "castor/tape/tapeserver/daemon/TapeSessionStats.hpp"
#include "castor/tape/tapeserver/daemon/MemBlock.hpp"
......
......@@ -3,4 +3,4 @@ set_property(SOURCE DriveGeneric.cpp PROPERTY COMPILE_FLAGS -fno-strict-aliasing
target_link_libraries(TapeDrive SCSI)
add_executable(TapeDriveReadWriteTest TapeDriveReadWriteTest.cpp)
target_link_libraries(TapeDriveReadWriteTest TapeDrive Exception SCSI System Utils castorcommon castorclient ${GTEST_LIBRARY} gmock pthread)
target_link_libraries(TapeDriveReadWriteTest TapeDrive SCSI System Utils castorcommon castorclient ${GTEST_LIBRARY} gmock pthread)
......@@ -47,7 +47,7 @@ drives::DriveInterface * drives::DriveFactory(SCSI::DeviceInfo di,
return new FakeDrive();
}
} else {
throw Exception(std::string("Unsupported drive type: ") + di.product);
throw castor::exception::Exception(std::string("Unsupported drive type: ") + di.product);
}
}
......@@ -234,7 +234,7 @@ drives::positionInfo drives::DriveGeneric::getPositionInfo()
* obtain the current position and number of bytes in the object buffer.
* (note) For T10000 we have only SHORT FORM.
*/
throw Exception(std::string("An overflow has occurred in getPostitionInfo"));
throw castor::exception::Exception(std::string("An overflow has occurred in getPostitionInfo"));
}
return posInfo;
}
......
......@@ -115,7 +115,7 @@ namespace drives {
* @return structure containing various booleans, and error conditions.
*/
virtual driveStatus getDriveStatus() {
throw Exception("Not implemented");
throw castor::exception::Exception("Not implemented");
}
virtual bool waitUntilReady(int timeoutSecond) {
......@@ -194,7 +194,7 @@ namespace drives {
* @return error code and string containing the error description
*/
virtual tapeError getTapeError() {
throw Exception("Not implemented");
throw castor::exception::Exception("Not implemented");
}
/**
......
......@@ -28,7 +28,7 @@
#include "castor/tape/tapeserver/SCSI/Structures.hpp"
#include "castor/tape/tapeserver/SCSI/Exception.hpp"
#include "castor/tape/tapeserver/drive/mtio_add.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "castor/exception/Exception.hpp"
#include "castor/tape/tapeserver/system/Wrapper.hpp"
/**
......@@ -100,7 +100,7 @@ namespace drives {
* Exception reported by drive functions when trying to read beyond
* end of data
*/
class EndOfData: public Exception {
class EndOfData: public castor::exception::Exception {
public:
EndOfData(const std::string w=""): Exception(w) {}
};
......@@ -109,7 +109,7 @@ namespace drives {
* Exception reported by drive functions when trying to write beyond
* end of medium
*/
class EndOfMedium: public Exception {
class EndOfMedium: public castor::exception::Exception {
public:
EndOfMedium(const std::string w=""): Exception(w) {}
};
......@@ -117,7 +117,7 @@ namespace drives {
/**
* Exception reported by ReadExactBlock when the size is not right
*/
class UnexpectedSize: public Exception {
class UnexpectedSize: public castor::exception::Exception {
public:
UnexpectedSize(const std::string w=""): Exception(w) {}
};
......@@ -125,7 +125,7 @@ namespace drives {
/**
* Exception reported by ReadFileMark when finding a data block
*/
class NotAFileMark: public Exception {
class NotAFileMark: public castor::exception::Exception {
public:
NotAFileMark(const std::string w=""): Exception(w) {}
};
......
......@@ -32,10 +32,10 @@ castor::tape::tapeserver::drives::FakeDrive::FakeDrive() throw() : m_current_pos
m_tape.reserve(max_fake_drive_record_length);
}
castor::tape::tapeserver::drives::compressionStats castor::tape::tapeserver::drives::FakeDrive::getCompression() {
throw Exception("FakeDrive::getCompression Not implemented");
throw castor::exception::Exception("FakeDrive::getCompression Not implemented");
}
void castor::tape::tapeserver::drives::FakeDrive::clearCompressionStats() {
throw Exception("FakeDrive::clearCompressionStats Not implemented");
throw castor::exception::Exception("FakeDrive::clearCompressionStats Not implemented");
}
castor::tape::tapeserver::drives::deviceInfo castor::tape::tapeserver::drives::FakeDrive::getDeviceInfo() {
deviceInfo devInfo;
......@@ -46,7 +46,7 @@ castor::tape::tapeserver::drives::deviceInfo castor::tape::tapeserver::drives::F
return devInfo;
}
std::string castor::tape::tapeserver::drives::FakeDrive::getSerialNumber() {
throw Exception("FakeDrive::getSerialNumber Not implemented");
throw castor::exception::Exception("FakeDrive::getSerialNumber Not implemented");
}
void castor::tape::tapeserver::drives::FakeDrive::positionToLogicalObject(uint32_t blockId) {
m_current_position = blockId;
......@@ -60,19 +60,19 @@ castor::tape::tapeserver::drives::positionInfo castor::tape::tapeserver::drives:
return pos;
}
std::vector<std::string> castor::tape::tapeserver::drives::FakeDrive::getTapeAlerts() {
throw Exception("FakeDrive::getTapeAlerts Not implemented");
throw castor::exception::Exception("FakeDrive::getTapeAlerts Not implemented");
}
void castor::tape::tapeserver::drives::FakeDrive::setDensityAndCompression(bool compression, unsigned char densityCode) {
throw Exception("FakeDrive::setDensityAndCompression Not implemented");
throw castor::exception::Exception("FakeDrive::setDensityAndCompression Not implemented");
}
castor::tape::tapeserver::drives::driveStatus castor::tape::tapeserver::drives::FakeDrive::getDriveStatus() {
throw Exception("FakeDrive::getDriveStatus Not implemented");
throw castor::exception::Exception("FakeDrive::getDriveStatus Not implemented");
}
castor::tape::tapeserver::drives::tapeError castor::tape::tapeserver::drives::FakeDrive::getTapeError() {
throw Exception("FakeDrive::getTapeError Not implemented");
throw castor::exception::Exception("FakeDrive::getTapeError Not implemented");
}
void castor::tape::tapeserver::drives::FakeDrive::setSTBufferWrite(bool bufWrite) {
throw Exception("FakeDrive::setSTBufferWrite Not implemented");
throw castor::exception::Exception("FakeDrive::setSTBufferWrite Not implemented");
}
void castor::tape::tapeserver::drives::FakeDrive::fastSpaceToEOM(void) {
m_current_position = m_tape.size()-1;
......@@ -91,7 +91,7 @@ void castor::tape::tapeserver::drives::FakeDrive::spaceFileMarksBackwards(size_t
if(!m_tape[i].compare(filemark)) countdown--;
}
if(countdown) {
throw Exception("FakeDrive::spaceFileMarksBackwards");
throw castor::exception::Exception("FakeDrive::spaceFileMarksBackwards");
}
m_current_position = i-1; //BOT side of the filemark
}
......@@ -135,7 +135,7 @@ void castor::tape::tapeserver::drives::FakeDrive::writeBlock(const void * data,
}
ssize_t castor::tape::tapeserver::drives::FakeDrive::readBlock(void *data, size_t count) {
if(count < m_tape[m_current_position].size()) {
throw Exception("Block size too small in FakeDrive::readBlock");
throw castor::exception::Exception("Block size too small in FakeDrive::readBlock");
}
size_t bytes_copied = m_tape[m_current_position].copy((char *)data, m_tape[m_current_position].size());
m_current_position++;
......@@ -158,16 +158,16 @@ void castor::tape::tapeserver::drives::FakeDrive::readExactBlock(void *data, siz
std::stringstream exc;
exc << "Wrong block size in FakeDrive::readExactBlock. Expected: " << count << " Found: " << m_tape[m_current_position].size() << " Position: " << m_current_position << " String: " << m_tape[m_current_position] << std::endl;
exc << contentToString();
throw Exception(exc.str());
throw castor::exception::Exception(exc.str());
}
if(count != m_tape[m_current_position].copy((char *)data, count)) {
throw Exception("Failed FakeDrive::readExactBlock");
throw castor::exception::Exception("Failed FakeDrive::readExactBlock");
}
m_current_position++;
}
void castor::tape::tapeserver::drives::FakeDrive::readFileMark(std::string context) {
if(m_tape[m_current_position].compare(filemark)) {
throw Exception("Failed FakeDrive::readFileMark");
throw castor::exception::Exception("Failed FakeDrive::readFileMark");
}
m_current_position++;
}
......
/******************************************************************************
*
* 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
*****************************************************************************/
#define _XOPEN_SOURCE 600
#include "Exception.hpp"
#include <stdlib.h>
#include <errno.h>
/* We want the thread safe (and portable) version of strerror */
#include <string.h>
#include <sstream>
#include <iosfwd>
/* TODO remove me: it should be temporary */
#include <iostream>
using namespace castor::tape;
void Exception::setWhat(const std::string& what) {
getMessage() << what;
}
Exception::Exception(const Exception &ex): castor::exception::Exception(0) {
getMessage() << ex.getMessageValue();
m_backtrace = ex.m_backtrace;
}
/******************************************************************************
*
* 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 "castor/exception/Exception.hpp"
#include <exception>
#include <string>
namespace castor {
namespace tape {
class Exception: public castor::exception::Exception {
public:
Exception(const std::string& what): castor::exception::Exception(SEINTERNAL) { setWhat(what); }
// Copy operator needed to throw anonymous instance (throw myClass("some failure."))
Exception(const Exception &ex);
virtual ~Exception() throw() {};
protected:
void setWhat(const std::string &w);
};
} //namespace tape
} //namespace castor
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