source: trunk/contrib/cppunit-1.12.2/include/cppunit/Exception.h @ 876

Last change on this file since 876 was 876, checked in by sam, 9 years ago

contrib: add a precompiled Win32 version of CppUnit and update build system
accordingly.

File size: 2.1 KB
Line 
1#ifndef CPPUNIT_EXCEPTION_H
2#define CPPUNIT_EXCEPTION_H
3
4#include <cppunit/Portability.h>
5#include <cppunit/Message.h>
6#include <cppunit/SourceLine.h>
7#include <exception>
8
9
10CPPUNIT_NS_BEGIN
11
12
13/*! \brief Exceptions thrown by failed assertions.
14 * \ingroup BrowsingCollectedTestResult
15 *
16 * Exception is an exception that serves
17 * descriptive strings through its what() method
18 */
19class CPPUNIT_API Exception : public std::exception
20{
21public:
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.
25   */
26  Exception( const Message &message = Message(),
27             const SourceLine &sourceLine = SourceLine() );
28
29#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
30  /*!
31   * \deprecated Use other constructor instead.
32   */
33  Exception( std::string  message,
34             long lineNumber,
35             std::string fileName );
36#endif
37
38  /*! \brief Constructs a copy of an exception.
39   * \param other Exception to copy.
40   */
41  Exception( const Exception &other );
42
43  /// Destructs the exception
44  virtual ~Exception() throw();
45
46  /// Performs an assignment
47  Exception &operator =( const Exception &other );
48
49  /// Returns descriptive message
50  const char *what() const throw();
51
52  /// Location where the error occured
53  SourceLine sourceLine() const;
54
55  /// Message related to the exception.
56  Message message() const;
57
58  /// Set the message.
59  void setMessage( const Message &message );
60
61#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
62  /// The line on which the error occurred
63  long lineNumber() const;
64
65  /// The file in which the error occurred
66  std::string fileName() const;
67
68  static const std::string UNKNOWNFILENAME;
69  static const long UNKNOWNLINENUMBER;
70#endif
71
72  /// Clones the exception.
73  virtual Exception *clone() const;
74
75protected:
76  // VC++ does not recognize call to parent class when prefixed
77  // with a namespace. This is a workaround.
78  typedef std::exception SuperClass;
79
80  Message m_message;
81  SourceLine m_sourceLine;
82  std::string m_whatMessage;
83};
84
85
86CPPUNIT_NS_END
87
88
89#endif // CPPUNIT_EXCEPTION_H
90
Note: See TracBrowser for help on using the repository browser.