summaryrefslogtreecommitdiffstats
blob: bf5fcacf6657924a8b08e286ef49759291aa966d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef CPPUNIT_EXCEPTION_H
#define CPPUNIT_EXCEPTION_H

#include <cppunit/Portability.h>
#include <cppunit/Message.h>
#include <cppunit/SourceLine.h>
#include <exception>


CPPUNIT_NS_BEGIN


/*! \brief Exceptions thrown by failed assertions.
 * \ingroup BrowsingCollectedTestResult
 *
 * Exception is an exception that serves
 * descriptive strings through its what() method
 */
class CPPUNIT_API Exception : public std::exception
{
public:
  /*! \brief Constructs the exception with the specified message and source location.
   * \param message Message associated to the exception.
   * \param sourceLine Source location related to the exception.
   */
  Exception( const Message &message = Message(), 
             const SourceLine &sourceLine = SourceLine() );

#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
  /*!
   * \deprecated Use other constructor instead.
   */
  Exception( std::string  message, 
	     long lineNumber, 
	     std::string fileName );
#endif

  /*! \brief Constructs a copy of an exception.
   * \param other Exception to copy.
   */
  Exception( const Exception &other );

  /// Destructs the exception
  virtual ~Exception() throw();

  /// Performs an assignment
  Exception &operator =( const Exception &other );

  /// Returns descriptive message
  const char *what() const throw();

  /// Location where the error occured
  SourceLine sourceLine() const;

  /// Message related to the exception.
  Message message() const;

  /// Set the message.
  void setMessage( const Message &message );

#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
  /// The line on which the error occurred
  long lineNumber() const;

  /// The file in which the error occurred
  std::string fileName() const;

  static const std::string UNKNOWNFILENAME;
  static const long UNKNOWNLINENUMBER;
#endif

  /// Clones the exception.
  virtual Exception *clone() const;

protected:
  // VC++ does not recognize call to parent class when prefixed
  // with a namespace. This is a workaround.
  typedef std::exception SuperClass;

  Message m_message;
  SourceLine m_sourceLine;
  std::string m_whatMessage;
};


CPPUNIT_NS_END


#endif // CPPUNIT_EXCEPTION_H