Crazy Eddies GUI System  0.7.8
CEGUIExceptions.h
1 /***********************************************************************
2  filename: CEGUIExceptions.h
3  created: 20/2/2004
4  author: Paul D Turner, Frederico Jeronimo (fjeronimo)
5 
6  purpose: Defines exceptions used within the system
7 *************************************************************************/
8 /***************************************************************************
9 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30 #ifndef _CEGUIExceptions_h_
31 #define _CEGUIExceptions_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include <exception>
36 
37 // Start of CEGUI namespace section
38 namespace CEGUI
39 {
41 class CEGUIEXPORT Exception : public std::exception
42 {
43 public:
45  virtual ~Exception(void) throw();
46 
56  const String& getMessage(void) const
57  { return d_message; }
58 
67  const String& getName() const
68  { return d_name; }
69 
79  const String& getFileName(void) const
80  { return d_filename; }
81 
89  int getLine(void) const
90  { return d_line; }
91 
92  // override from std::exception.
93  const char* what() const throw();
94 
95 protected:
116  Exception(const String& message = "",
117  const String& name = "CEGUI::Exception",
118  const String& filename = "",
119  int line = 0);
120 
122  String d_message;
124  String d_filename;
126  String d_name;
128  int d_line;
130  String d_what;
131 };
132 
133 //----------------------------------------------------------------------------//
134 
136 class CEGUIEXPORT GenericException : public Exception
137 {
138 public:
160  GenericException(const String& message,
161  const String& file = "unknown", int line = 0) :
162  Exception(message, "CEGUI::GenericException", file, line)
163  {}
164 };
165 
183 #define GenericException(message) \
184  GenericException(message, __FILE__, __LINE__)
185 
186 //----------------------------------------------------------------------------//
187 
189 class CEGUIEXPORT UnknownObjectException : public Exception
190 {
191 public:
214  const String& file = "unknown", int line = 0) :
215  Exception(message, "CEGUI::UnknownObjectException", file, line)
216  {}
217 };
218 
236 #define UnknownObjectException(message) \
237  UnknownObjectException(message, __FILE__, __LINE__)
238 
239 //----------------------------------------------------------------------------//
240 
242 class CEGUIEXPORT InvalidRequestException : public Exception
243 {
244 public:
267  const String& file = "unknown", int line = 0) :
268  Exception(message, "CEGUI::InvalidRequestException", file, line)
269  {}
270 };
271 
289 #define InvalidRequestException(message) \
290  InvalidRequestException(message, __FILE__, __LINE__)
291 
292 //----------------------------------------------------------------------------//
293 
295 class CEGUIEXPORT FileIOException : public Exception
296 {
297 public:
319  FileIOException(const String& message,
320  const String& file = "unknown", int line = 0) :
321  Exception(message, "CEGUI::FileIOException", file, line)
322  {}
323 };
324 
342 #define FileIOException(message) \
343  FileIOException(message, __FILE__, __LINE__)
344 
345 //----------------------------------------------------------------------------//
346 
348 class CEGUIEXPORT RendererException : public Exception
349 {
350 public:
372  RendererException(const String& message,
373  const String& file = "unknown", int line = 0) :
374  Exception(message, "CEGUI::RendererException", file, line)
375  {}
376 };
377 
395 #define RendererException(message) \
396  RendererException(message, __FILE__, __LINE__)
397 
398 //----------------------------------------------------------------------------//
399 
406 class CEGUIEXPORT AlreadyExistsException : public Exception
407 {
408 public:
431  const String& file = "unknown", int line = 0) :
432  Exception(message, "CEGUI::AlreadyExistsException", file, line)
433  {}
434 };
435 
453 #define AlreadyExistsException(message) \
454  AlreadyExistsException(message, __FILE__, __LINE__)
455 
456 //----------------------------------------------------------------------------//
457 
459 class CEGUIEXPORT MemoryException : public Exception
460 {
461 public:
483  MemoryException(const String& message,
484  const String& file = "unknown", int line = 0) :
485  Exception(message, "CEGUI::MemoryException", file, line)
486  {}
487 };
488 
506 #define MemoryException(message) \
507  MemoryException(message, __FILE__, __LINE__)
508 
509 //----------------------------------------------------------------------------//
510 
512 class CEGUIEXPORT NullObjectException : public Exception
513 {
514 public:
536  NullObjectException(const String& message,
537  const String& file = "unknown", int line = 0) :
538  Exception(message, "CEGUI::NullObjectException", file, line)
539  {}
540 };
541 
559 #define NullObjectException(message) \
560  NullObjectException(message, __FILE__, __LINE__)
561 
562 //----------------------------------------------------------------------------//
563 
569 class CEGUIEXPORT ObjectInUseException : public Exception
570 {
571 public:
593  ObjectInUseException(const String& message,
594  const String& file = "unknown", int line = 0) :
595  Exception(message, "CEGUI::ObjectInUseException", file, line)
596  {}
597 };
598 
616 #define ObjectInUseException(message) \
617  ObjectInUseException(message, __FILE__, __LINE__)
618 
619 //----------------------------------------------------------------------------//
620 
622 class CEGUIEXPORT ScriptException : public Exception
623 {
624 public:
646  ScriptException(const String& message,
647  const String& file = "unknown", int line = 0) :
648  Exception(message, "CEGUI::ScriptException", file, line)
649  {}
650 };
651 
669 #define ScriptException(message) \
670  ScriptException(message, __FILE__, __LINE__)
671 
672 
673 //----------------------------------------------------------------------------//
674 
675 } // End of CEGUI namespace section
676 
677 
678 #endif // end of guard _CEGUIExceptions_h_