summaryrefslogtreecommitdiff
path: root/include/cppunit/Exception.h
blob: 1cf7548a3004d1bafa0fa709b7d04b2f6b56faa0 (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
#ifndef CPPUNIT_EXCEPTION_H
#define CPPUNIT_EXCEPTION_H

#include <exception>
#include <string>

namespace CppUnit {

  /** 
   * Exception is an exception that serves
   * descriptive strings through its what() method
   *
   */

  class Exception : public std::exception
  {
    public:
      class Type
      {
      public:
        Type( std::string type ) : m_type ( type ) {}

        bool operator ==( const Type &other ) const
        {
          return m_type == other.m_type;
        }
      private:
        const std::string m_type;
      };


      Exception( std::string  message = "", 
                 long lineNumber = UNKNOWNLINENUMBER, 
                 std::string fileName = UNKNOWNFILENAME);
      Exception (const Exception& other);

      virtual ~Exception () throw();

      Exception& operator= (const Exception& other);

      const char *what() const throw ();

      long lineNumber ();
      std::string fileName ();

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

      virtual Exception *clone() const;

      virtual bool isInstanceOf( const Type &type ) const;

      static Type type();

    private:
      std::string m_message;
      long m_lineNumber;
      std::string m_fileName;
  };

} // namespace CppUnit

#endif // CPPUNIT_EXCEPTION_H