Athena IO Library
IOException.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 IOEXCEPTION_HPP
17 #define IOEXCEPTION_HPP
18 
19 #include "Athena/Exception.hpp"
20 
21 
22 namespace Athena
23 {
24 namespace error
25 {
36 class IOException : public Exception
37 {
38 public:
42  inline IOException(const std::string& message, const std::string& file, const std::string& function, const int line) :
43  Exception(message, file, function, line)
44  {
45  m_exceptionName = "IOException";
46  }
47 };
48 
49 } // error
50 } // Athena
51 
52 #ifdef _MSC_VER
53 #define THROW_IO_EXCEPTION(args, ...) \
54  do { \
55  if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return; \
56  } else {
57 std::string msg = Athena::utility::sprintf(args, __VA_ARGS__);
58 \
59 throw Athena::error::IOException(std::string("IOException: ") + msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__);
60 \
61 } \
62 
63 } while (0)
64 #elif defined(__GNUC__)
65 #define THROW_IO_EXCEPTION(args...) \
66  do { \
67  if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return; \
68  } else { std::string msg = Athena::utility::sprintf(args); \
69  throw Athena::error::IOException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
70  } \
71  } while(0)
72 #endif
73 
74 #ifdef _MSC_VER
75 #define THROW_IO_EXCEPTION_RETURN(ret, args, ...) \
76  do { \
77  if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return ret; \
78  } else {
79  std::string msg = Athena::utility::sprintf(args, __VA_ARGS__);
80 
81 \
82 throw Athena::error::IOException(std::string("IOException: ") + msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__);
83 \
84 } \
85 
86 } while (0)
87 #elif defined(__GNUC__)
88 #define THROW_IO_EXCEPTION_RETURN(ret, args...) \
89  do { \
90  if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return ret; \
91  } else { std::string msg = Athena::utility::sprintf(args); \
92  throw Athena::error::IOException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
93  } \
94  } while(0)
95 #endif
96 
97 #endif // IOEXCEPTION_HPP
IOException(const std::string &message, const std::string &file, const std::string &function, const int line)
The constructor for an IOException.
Definition: IOException.hpp:42
std::string message() const
Returns the Error message of the exception.
Definition: Exception.hpp:56
An excpeption thrown on inappropriate IO calls.
Definition: IOException.hpp:36
The baseclass for all Exceptions.
Definition: Exception.hpp:38