Athena IO Library
InvalidDataException.hpp
1 // This file is part of libAthena.
2 //
3 // libAthena is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // libAthena is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with libAthena. If not, see <http://www.gnu.org/licenses/>
15 
16 #ifndef INVALIDDATAEXCEPTION_HPP
17 #define INVALIDDATAEXCEPTION_HPP
18 
19 #include "Athena/Exception.hpp"
20 #include <sstream>
21 
22 namespace Athena
23 {
24 namespace error
25 {
36 {
37 public:
38  inline InvalidDataException(const std::string& error, const std::string& file, const std::string& function, const int line)
39  : Exception(("InvalidDataException") + error, file, function, line)
40  {
41  m_exceptionName = "InvalidDataException";
42  }
43 };
44 } // error
45 } // Athena
46 
47 #ifdef _MSC_VER
48 #define THROW_INVALID_DATA_EXCEPTION(args, ...) \
49  do { \
50  if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return; } \
51  else { std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \
52  throw Athena::error::InvalidDataException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
53  } \
54  } while(0)
55 #elif defined(__GNUC__)
56 #define THROW_INVALID_DATA_EXCEPTION(args...) \
57  do { if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return; } \
58  else { std::string msg = Athena::utility::sprintf(args); \
59  throw Athena::error::InvalidDataException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
60  } \
61  } while(0)
62 #endif
63 
64 #ifdef _MSC_VER
65 #define THROW_INVALID_DATA_EXCEPTION(args, ...) \
66  do { \
67  if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return; } \
68  else { std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \
69  throw Athena::error::InvalidDataException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
70  } \
71  } while(0)
72 #elif defined(__GNUC__)
73 #define THROW_INVALID_DATA_EXCEPTION_RETURN(ret, args...) \
74  do { if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return ret; } \
75  else { std::string msg = Athena::utility::sprintf(args); \
76  throw Athena::error::InvalidDataException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
77  } \
78  } while(0)
79 #endif
80 #endif // INVALIDDATAEXCEPTION_HPP
Exception(const std::string &message, const std::string &file, const std::string &function, const int line)
The constructor for an Exception.
Definition: Exception.hpp:44
An exception thrown on Invalid Data calls.
The baseclass for all Exceptions.
Definition: Exception.hpp:38