1
#ifndef CPPUNIT_EXCEPTION_H
2
#define CPPUNIT_EXCEPTION_H
4
#include <cppunit/Portability.h>
5
#include <cppunit/Message.h>
6
#include <cppunit/SourceLine.h>
13
/*! \brief Exceptions thrown by failed assertions.
14
* \ingroup BrowsingCollectedTestResult
16
* Exception is an exception that serves
17
* descriptive strings through its what() method
19
class CPPUNIT_API Exception : public std::exception
22
/*! \brief Constructs the exception with the specified message and source location.
23
* \param message Message associated to the exception.
24
* \param sourceLine Source location related to the exception.
26
Exception( const Message &message = Message(),
27
const SourceLine &sourceLine = SourceLine() );
29
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
31
* \deprecated Use other constructor instead.
33
Exception( std::string message,
35
std::string fileName );
38
/*! \brief Constructs a copy of an exception.
39
* \param other Exception to copy.
41
Exception( const Exception &other );
43
/// Destructs the exception
44
virtual ~Exception() throw();
46
/// Performs an assignment
47
Exception &operator =( const Exception &other );
49
/// Returns descriptive message
50
const char *what() const throw();
52
/// Location where the error occured
53
SourceLine sourceLine() const;
55
/// Message related to the exception.
56
Message message() const;
59
void setMessage( const Message &message );
61
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
62
/// The line on which the error occurred
63
long lineNumber() const;
65
/// The file in which the error occurred
66
std::string fileName() const;
68
static const std::string UNKNOWNFILENAME;
69
static const long UNKNOWNLINENUMBER;
72
/// Clones the exception.
73
virtual Exception *clone() const;
76
// VC++ does not recognize call to parent class when prefixed
77
// with a namespace. This is a workaround.
78
typedef std::exception SuperClass;
81
SourceLine m_sourceLine;
82
std::string m_whatMessage;
89
#endif // CPPUNIT_EXCEPTION_H