~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/framework/Exception.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  File:       Exception.h
 
3
 *  Summary:    The class which defines the base class for exceptions.
 
4
 *  Written by: nikal and xmp
 
5
 *
 
6
 *  Copyright (C) 2002 nikal, xmp. 
 
7
 *  This code is distributed under the GPL.
 
8
 *  See file COPYING for details. 
 
9
 *
 
10
 *  Change History (most recent first):    
 
11
 *
 
12
 */
 
13
/*
 
14
    Copyright (C) 2002  Nikal, Xmp
 
15
    Copyright (C) 2008  Erik Hjortsberg
 
16
 
 
17
    This program is free software; you can redistribute it and/or modify
 
18
    it under the terms of the GNU General Public License as published by
 
19
    the Free Software Foundation; either version 2 of the License, or
 
20
    (at your option) any later version.
 
21
 
 
22
    This program is distributed in the hope that it will be useful,
 
23
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
24
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
25
    GNU General Public License for more details.
 
26
 
 
27
    You should have received a copy of the GNU General Public License
 
28
    along with this program; if not, write to the Free Software
 
29
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
30
*/
 
31
 
 
32
 
 
33
#ifndef EMBER_EXCEPTION_H
 
34
#define EMBER_EXCEPTION_H
 
35
 
 
36
#include <string>
 
37
#include <exception>
 
38
 
 
39
namespace Ember 
 
40
{
 
41
class Exception;
 
42
/**
 
43
 *      The default way to throw exceptions is to use one of the following macros.
 
44
 */
 
45
 
 
46
// #define THROW(message) throw Exception(message, __FILE__, __LINE__);
 
47
// #define THROW1(message, p1) throw Exception(message, __FILE__, __LINE__, p1);
 
48
// #define THROW2(message, p1, p2) throw Exception(message, __FILE__, __LINE__, p1, p2);
 
49
// #define THROW3(message, p1, p2, p3) throw Exception(message, __FILE__, __LINE__, p1, p2, p3);
 
50
 
 
51
 
 
52
const int EXCEPTION_TEXT_SIZE = 1024;
 
53
 
 
54
/**
 
55
 * The base class for all exceptions that are thrown within Ember.
 
56
 *
 
57
 * @author Nikal
 
58
 * @author Xmp (Martin Pollard)
 
59
 * @author Erik Hjortsberg <erik.hjortsberg@gmail.com>
 
60
 *
 
61
 */
 
62
class Exception : public std::exception
 
63
{
 
64
 
 
65
public:
 
66
 
 
67
        /**
 
68
        * Creates a new generic Exception using default values.
 
69
        */
 
70
        Exception();
 
71
 
 
72
        /**
 
73
        * Creates a new generic Exception using the specified error description.
 
74
        * @param error A descriptive string of the error.
 
75
        */
 
76
        Exception(const std::string& error);
 
77
 
 
78
        /**
 
79
        * Creates a new generic Exception using the specified error string, file and line
 
80
        * occurence.
 
81
        * @param error A descriptive string of the error.
 
82
        * @param file The file in which the error occured.
 
83
        * @param line The line on which the error occurred.
 
84
        */
 
85
    Exception(const std::string& error, const std::string & file, int line, ...);
 
86
 
 
87
        virtual ~Exception() throw();
 
88
 
 
89
        /**
 
90
        *    @brief Gets a descriptive string of the exception.
 
91
        * @see what()
 
92
        * @return A description of the error.
 
93
        */
 
94
        const std::string& getError() const;
 
95
     
 
96
        /**
 
97
        * @brief Sets a descriptive string for this error.
 
98
        * @param error The description of the error.
 
99
        */
 
100
        void setError(const std::string& error);
 
101
 
 
102
        /**
 
103
        *   @brief Gets a descriptive string of the exception.
 
104
        * @see getError()
 
105
        * @return A description of the error.
 
106
        */
 
107
        virtual const char* what() const throw();
 
108
        
 
109
        private:
 
110
 
 
111
        /**
 
112
        A description of the error.
 
113
        */
 
114
        std::string mErrorDescription;
 
115
        
 
116
        /**
 
117
        The file in which the error occurred.
 
118
        */
 
119
        std::string mFile;
 
120
        
 
121
        /**
 
122
        The line on which the error occurred.
 
123
        */
 
124
        int     mLine;
 
125
 
 
126
 
 
127
};
 
128
 
 
129
 
 
130
}
 
131
#endif