Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickups/src/ois/OISException.h @ 2255

Last change on this file since 2255 was 1505, checked in by rgrieder, 17 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1/*
2The zlib/libpng License
3
4Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
12
13    1. The origin of this software must not be misrepresented; you must not claim that
14                you wrote the original software. If you use this software in a product,
15                an acknowledgment in the product documentation would be appreciated but is
16                not required.
17
18    2. Altered source versions must be plainly marked as such, and must not be
19                misrepresented as being the original software.
20
21    3. This notice may not be removed or altered from any source distribution.
22*/
23#ifndef _OIS_EXCEPTION_HEADER_
24#define _OIS_EXCEPTION_HEADER_
25#include "OISPrereqs.h"
26#include <exception>
27
28namespace OIS
29{
30        //! Simple enum's for dealing with exceptions
31    enum OIS_ERROR
32        {
33                E_InputDisconnected,
34                E_InputDeviceNonExistant,
35                E_InputDeviceNotSupported,
36                E_DeviceFull,
37                E_NotSupported,
38                E_NotImplemented,
39                E_Duplicate,
40                E_InvalidParam,
41                E_General
42        };
43
44        /**
45        @remarks
46                Class for handling OIS exceptions. Much cleaner than checking every method for reurn value.
47                Inherits from std::exception so you can simply log those messages if you want to be generic.
48                Also note that this has a source file now since OSX was not finding the OIS::Exception symbol
49                which would cause program abortion with now correponding exception type.
50        */
51        class _OISExport Exception : public std::exception
52        {
53                //! Hidden default
54                Exception() : eType(E_General), eLine(0), eFile(0) {}
55        public:
56                //! Creates exception object
57                Exception( OIS_ERROR err, const char* str, int line, const char *file )
58                        : eType(err), eLine(line), eFile(file), eText(str) {}
59
60                virtual const char* what() const throw()
61            { return eText; }
62
63                //! The type of exception raised
64                const OIS_ERROR eType;
65                //! The line number it occurred on
66                const int eLine;
67                //! The source file
68                const char* eFile;
69                //! A message passed along when the exception was raised
70                const char* eText;
71        };
72}
73
74//! Use this macro to handle exceptions easily
75#define OIS_EXCEPT( err, str ) throw( OIS::Exception(err, str, __LINE__, __FILE__) )
76
77#endif //_OIS_EXCEPTION_HEADER_
Note: See TracBrowser for help on using the repository browser.