Crazy Eddie's GUI System 0.8.7
Exceptions.h
1/***********************************************************************
2 created: 20/2/2004
3 author: Paul D Turner, Frederico Jeronimo (fjeronimo)
4
5 purpose: Defines exceptions used within the system
6*************************************************************************/
7/***************************************************************************
8* Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
9*
10* Permission is hereby granted, free of charge, to any person obtaining
11* a copy of this software and associated documentation files (the
12* "Software"), to deal in the Software without restriction, including
13* without limitation the rights to use, copy, modify, merge, publish,
14* distribute, sublicense, and/or sell copies of the Software, and to
15* permit persons to whom the Software is furnished to do so, subject to
16* the following conditions:
17*
18* The above copyright notice and this permission notice shall be
19* included in all copies or substantial portions of the Software.
20*
21* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27* OTHER DEALINGS IN THE SOFTWARE.
28***************************************************************************/
29#ifndef _CEGUIExceptions_h_
30#define _CEGUIExceptions_h_
31
32#include "CEGUI/Base.h"
33#include "CEGUI/String.h"
34#include <exception>
35
36#if defined(_MSC_VER)
37# pragma warning(push)
38# pragma warning(disable : 4275)
39#endif
40
41
42// Start of CEGUI namespace section
43namespace CEGUI
44{
46class CEGUIEXPORT Exception :
47 public std::exception,
48 public AllocatedObject<Exception>
49{
50public:
52 virtual ~Exception(void) throw();
53
63 const String& getMessage(void) const
64 { return d_message; }
65
74 const String& getName() const
75 { return d_name; }
76
86 const String& getFileName(void) const
87 { return d_filename; }
88
96 int getLine(void) const
97 { return d_line; }
98
108 const String& getFunctionName(void) const
109 { return d_function; }
110
111 // override from std::exception.
112 const char* what() const throw();
113
126 static void setStdErrEnabled(bool enabled);
127
135 static bool isStdErrEnabled();
136
137protected:
139 static bool d_stdErrEnabled;
140
165 Exception(const String& message = "",
166 const String& name = "CEGUI::Exception",
167 const String& filename = "",
168 int line = 0,
169 const String& function = "");
170
172 String d_message;
174 String d_name;
176 String d_filename;
178 int d_line;
180 String d_function;
182 String d_what;
183};
184
185//----------------------------------------------------------------------------//
186
188class CEGUIEXPORT GenericException : public Exception
189{
190public:
216 GenericException(const String& message,
217 const String& file = "unknown", int line = 0,
218 const String& function = "unknown") :
219 Exception(message, "CEGUI::GenericException", file, line, function)
220 {}
221};
222
240#define GenericException(message) \
241 GenericException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
242
243//----------------------------------------------------------------------------//
244
246class CEGUIEXPORT UnknownObjectException : public Exception
247{
248public:
275 const String& file = "unknown", int line = 0,
276 const String& function = "unknown") :
277 Exception(message, "CEGUI::UnknownObjectException", file, line, function)
278 {}
279};
280
298#define UnknownObjectException(message) \
299 UnknownObjectException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
300
301//----------------------------------------------------------------------------//
302
304class CEGUIEXPORT InvalidRequestException : public Exception
305{
306public:
333 const String& file = "unknown", int line = 0,
334 const String& function = "unknown") :
335 Exception(message, "CEGUI::InvalidRequestException", file, line, function)
336 {}
337};
338
356#define InvalidRequestException(message) \
357 InvalidRequestException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
358
359//----------------------------------------------------------------------------//
360
362class CEGUIEXPORT FileIOException : public Exception
363{
364public:
390 FileIOException(const String& message,
391 const String& file = "unknown", int line = 0,
392 const String& function = "unknown") :
393 Exception(message, "CEGUI::FileIOException", file, line, function)
394 {}
395};
396
414#define FileIOException(message) \
415 FileIOException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
416
417//----------------------------------------------------------------------------//
418
420class CEGUIEXPORT RendererException : public Exception
421{
422public:
448 RendererException(const String& message,
449 const String& file = "unknown", int line = 0,
450 const String& function = "unknown") :
451 Exception(message, "CEGUI::RendererException", file, line, function)
452 {}
453};
454
472#define RendererException(message) \
473 ::CEGUI::RendererException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
474
475//----------------------------------------------------------------------------//
476
483class CEGUIEXPORT AlreadyExistsException : public Exception
484{
485public:
512 const String& file = "unknown", int line = 0,
513 const String& function = "unknown") :
514 Exception(message, "CEGUI::AlreadyExistsException", file, line, function)
515 {}
516};
517
535#define AlreadyExistsException(message) \
536 AlreadyExistsException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
537
538//----------------------------------------------------------------------------//
539
541class CEGUIEXPORT MemoryException : public Exception
542{
543public:
569 MemoryException(const String& message,
570 const String& file = "unknown", int line = 0,
571 const String& function = "unknown") :
572 Exception(message, "CEGUI::MemoryException", file, line, function)
573 {}
574};
575
593#define MemoryException(message) \
594 MemoryException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
595
596//----------------------------------------------------------------------------//
597
599class CEGUIEXPORT NullObjectException : public Exception
600{
601public:
628 const String& file = "unknown", int line = 0,
629 const String& function = "unknown") :
630 Exception(message, "CEGUI::NullObjectException", file, line, function)
631 {}
632};
633
651#define NullObjectException(message) \
652 NullObjectException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
653
654//----------------------------------------------------------------------------//
655
661class CEGUIEXPORT ObjectInUseException : public Exception
662{
663public:
690 const String& file = "unknown", int line = 0,
691 const String& function = "unknown") :
692 Exception(message, "CEGUI::ObjectInUseException", file, line, function)
693 {}
694};
695
713#define ObjectInUseException(message) \
714 ObjectInUseException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
715
716//----------------------------------------------------------------------------//
717
719class CEGUIEXPORT ScriptException : public Exception
720{
721public:
747 ScriptException(const String& message,
748 const String& file = "unknown", int line = 0,
749 const String& function = "unknown") :
750 Exception(message, "CEGUI::ScriptException", file, line, function)
751 {}
752};
753
771#define ScriptException(message) \
772 ScriptException(message, __FILE__, __LINE__, CEGUI_FUNCTION_NAME)
773
774
775//----------------------------------------------------------------------------//
776
777} // End of CEGUI namespace section
778
779#if defined(_MSC_VER)
780# pragma warning(pop)
781#endif
782
783#endif // end of guard _CEGUIExceptions_h_
Definition: MemoryAllocatedObject.h:110
Exception class used when an attempt is made create a named object of a particular type when an objec...
Definition: Exceptions.h:484
AlreadyExistsException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the already exists exception by calling the base class.
Definition: Exceptions.h:511
Root exception class used within the GUI system.
Definition: Exceptions.h:49
virtual ~Exception(void)
Virtual destructor.
const String & getFunctionName(void) const
Return a reference to the String object containing the name of the function where the exception occur...
Definition: Exceptions.h:108
const String & getMessage(void) const
Return a reference to the String object describing the reason for the exception being thrown.
Definition: Exceptions.h:63
int getLine(void) const
Return the line number where the exception occurred.
Definition: Exceptions.h:96
const String & getFileName(void) const
Return a reference to the String object containing the name of the file where the exception occurred.
Definition: Exceptions.h:86
const String & getName() const
Return a reference to the String object containing the exception name (i.e. class type).
Definition: Exceptions.h:74
Exception class used when a file handling problem occurs.
Definition: Exceptions.h:363
FileIOException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the file IO exception by calling the base class.
Definition: Exceptions.h:390
Exception class used when none of the other classes are applicable.
Definition: Exceptions.h:189
GenericException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the generic exception by calling the base class.
Definition: Exceptions.h:216
Exception class used when some impossible request was made of the system.
Definition: Exceptions.h:305
InvalidRequestException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the invalid request exception by calling the base class.
Definition: Exceptions.h:332
Exception class used when a memory handling error is detected.
Definition: Exceptions.h:542
MemoryException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the memory exception by calling the base class.
Definition: Exceptions.h:569
Exception class used when some required object or parameter is null.
Definition: Exceptions.h:600
NullObjectException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the null object exception by calling the base class.
Definition: Exceptions.h:627
Exception class used when some attempt to delete, remove, or otherwise invalidate some object that is...
Definition: Exceptions.h:662
ObjectInUseException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the object in use exception by calling the base class.
Definition: Exceptions.h:689
Exception class used for problems in the rendering subsystem classes.
Definition: Exceptions.h:421
RendererException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the renderer exception by calling the base class.
Definition: Exceptions.h:448
Exception class used for issues in scripting subsystem.
Definition: Exceptions.h:720
ScriptException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the script exception by calling the base class.
Definition: Exceptions.h:747
String class used within the GUI system.
Definition: String.h:64
Exception class used when a request was made for an unknown object.
Definition: Exceptions.h:247
UnknownObjectException(const String &message, const String &file="unknown", int line=0, const String &function="unknown")
Constructor that is responsible for logging the unknown object exception by calling the base class.
Definition: Exceptions.h:274
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1