/src/ois/includes/OISException.h

https://bitbucket.org/cabalistic/ogredeps/ · C Header · 78 lines · 34 code · 7 blank · 37 comment · 0 complexity · 1113728428b2ea96a9e6af487256dbc1 MD5 · raw file

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