File: exception.h

package info (click to toggle)
packagesearch 2.7.5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 3,248 kB
  • ctags: 2,160
  • sloc: cpp: 12,397; perl: 252; makefile: 69; sh: 13
file content (63 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (10)
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
//
// C++ Interface: exception
//
// Description: 
//
//
// Author: Benjamin Mesing <bensmail@gmx.net>, (C) 2004
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef __EXCEPTION_H_2004_06_15
#define __EXCEPTION_H_2004_06_15

#include <string>

using namespace std;

namespace NException {

/** Base class for custom exceptions.
  * 
  * @author Benjamin Mesing
  */
class Exception{
public:
	Exception();
	virtual ~Exception();
	/** @returns a string descibing the problem. */
	virtual string description() const =0;
};

/** Class that stores the error message in a simple string.
  * 
  * @author Benjamin Mesing
  */
class SimpleString : virtual public Exception
{
	string _description;
public:
	/** Create an exception containing a simple string. */
	SimpleString(const string& description)	{ _description = description; }
	virtual string description() const	{ return _description; }
};

/** @brief Errors which result from wrong code - which are not caused by user interaction. */
class ProgrammerException : virtual public SimpleString
{
public:
	ProgrammerException(const string& description) : SimpleString(description)	{}
};

/** @brief Errors which result from user interaction. */
class RuntimeException : virtual public SimpleString
{
public:
	RuntimeException(const string& description) : SimpleString(description)	{}
};


};

#endif	//  __EXCEPTION_H_2004_06_15