Subversion Repositories HomeAutomation

Rev

Rev 1947 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *  Copyright (C) 2012  Mattias Runge
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #ifndef EXCEPTION_H
  22. #define EXCEPTION_H
  23.  
  24. #include <iostream>
  25. #include <stdexcept>
  26. #include <exception>
  27. #include <stdio.h>
  28. #include <stdint.h>
  29.  
  30. namespace atom {
  31. namespace exception {
  32.  
  33. #define CREATE_EXCEPTION(name, string)                                        \
  34.   class name : public std::exception                                          \
  35.   {                                                                           \
  36.     virtual const char* what() const throw()                                  \
  37.     {                                                                         \
  38.       return string;                                                          \
  39.     }                                                                         \
  40.   };
  41.  
  42.  
  43. CREATE_EXCEPTION(invalid_in_param,            "Inparameter failure");
  44. CREATE_EXCEPTION(missing_in_param,            "Missing inparameters");
  45. CREATE_EXCEPTION(connect_failed,              "Connection failed");
  46. CREATE_EXCEPTION(initialization_failed,       "Initialization failed");
  47. CREATE_EXCEPTION(missing_resource,            "Missing resource");
  48. CREATE_EXCEPTION(action_failed,               "Action failed");
  49. CREATE_EXCEPTION(unknown_state,               "Unrecognized state");
  50. CREATE_EXCEPTION(parsing_failed,              "Parsing failed");
  51.  
  52.  
  53. }; // namespace exception
  54. }; // namespace atom
  55.  
  56. #endif // EXCEPTION_H
  57.  
  58.