Exception.h
Go to the documentation of this file.
/*
* Robot Testing Framework
*
* Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ROBOTTESTINGFRAMEWORK_EXCEPTION_H
#define ROBOTTESTINGFRAMEWORK_EXCEPTION_H
#include <robottestingframework/TestMessage.h>
#include <exception>
namespace robottestingframework {
class Exception : public std::exception
{
public:
Exception(const Exception& other) :
std::exception(other),
expMessage(other.expMessage),
strMessage(other.strMessage)
{
}
Exception(const TestMessage& msg) :
expMessage(msg)
{
strMessage = expMessage.getMessage();
if (expMessage.getDetail().size())
strMessage += "(" + expMessage.getDetail() + ")";
}
virtual ~Exception() throw()
{
}
const char* what() const throw() override
{
return strMessage.c_str();
}
const TestMessage& message()
{
return expMessage;
}
private:
TestMessage expMessage;
std::string strMessage;
};
class TestFailureException : public Exception
{
public:
TestFailureException(const TestMessage& msg) :
Exception(msg)
{
}
TestFailureException(const TestFailureException& other) :
Exception(other)
{
}
};
class TestErrorException : public Exception
{
public:
TestErrorException(const TestMessage& msg) :
Exception(msg)
{
}
TestErrorException(const TestErrorException& other) :
Exception(other)
{
}
};
class FixtureException : public Exception
{
public:
FixtureException(const TestMessage& msg) :
Exception(msg)
{
}
FixtureException(const FixtureException& other) :
Exception(other)
{
}
};
} // namespace robottestingframework
#endif // ROBOTTESTINGFRAMEWORK_EXCEPTION_H
TestMessage.h
robottestingframework::Exception
The Exception is a generic exception.
Definition: Exception.h:35
robottestingframework::Exception::Exception
Exception(const Exception &other)
Definition: Exception.h:38
robottestingframework::Exception::expMessage
TestMessage expMessage
Definition: Exception.h:77
robottestingframework::Exception::Exception
Exception(const TestMessage &msg)
Definition: Exception.h:45
robottestingframework::Exception::~Exception
virtual ~Exception()
Definition: Exception.h:53
robottestingframework::Exception::what
const char * what() const override
what
Definition: Exception.h:61
robottestingframework::Exception::message
const TestMessage & message()
message
Definition: Exception.h:71
robottestingframework::Exception::strMessage
std::string strMessage
Definition: Exception.h:78
robottestingframework::FixtureException
The FixtureException class Ficture exception is used when a there is a probleme during fixture setup.
Definition: Exception.h:127
robottestingframework::FixtureException::FixtureException
FixtureException(const TestMessage &msg)
Definition: Exception.h:129
robottestingframework::FixtureException::FixtureException
FixtureException(const FixtureException &other)
Definition: Exception.h:134
robottestingframework::TestErrorException
The TestErrorException class Error exception is used when test breakdown due to an error in setup,...
Definition: Exception.h:107
robottestingframework::TestErrorException::TestErrorException
TestErrorException(const TestMessage &msg)
Definition: Exception.h:109
robottestingframework::TestErrorException::TestErrorException
TestErrorException(const TestErrorException &other)
Definition: Exception.h:114
robottestingframework::TestFailureException
The FailureException class Failure exception is used when a test or subtests fail.
Definition: Exception.h:87
robottestingframework::TestFailureException::TestFailureException
TestFailureException(const TestMessage &msg)
Definition: Exception.h:89
robottestingframework::TestFailureException::TestFailureException
TestFailureException(const TestFailureException &other)
Definition: Exception.h:94
robottestingframework::TestMessage
A formated message with details.
Definition: TestMessage.h:33
robottestingframework::TestMessage::getMessage
std::string getMessage()
getMessage returns the message string
robottestingframework::TestMessage::getDetail
std::string getDetail()
getMessage returns the detail string
robottestingframework
Definition: Arguments.h:25