FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
CoreException.hpp
1 /*
2  * Copyright 2011, 2012 Lukas Jirkovsky
3  *
4  * This file is part of FotoSHOCKcore.
5  *
6  * FotoSHOCKcore is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * FotoSHOCKcore 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 Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with FotoSHOCKcore. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef COREEXCEPTION_H
20 #define COREEXCEPTION_H
21 
22 #include <exception>
23 #include <string>
24 
25 namespace FotoSHOCKcore {
26 
28 class CoreException : public std::exception {
29  public:
30  CoreException(const char* message) {
31  m_what = message;
32  }
33  CoreException(const char* message, const char* file, int line) {
34  m_what = message;
35  m_what += " at ";
36  m_what += file;
37  m_what += ":";
38  m_what += line;
39  m_what += "\n";
40  }
41  virtual const char* what() const throw() {
42  return m_what.c_str();
43  }
44  virtual ~CoreException() throw() {}
45  private:
46  std::string m_what;
47 };
48 
49 class ArrayException : public CoreException {
50  public:
51  ArrayException(const char* message) : CoreException(message) {};
52  ArrayException(const char* message, const char* file, int line) : CoreException(message, file, line) {};
53  virtual ~ArrayException() throw() {}
54 };
55 
56 }
57 
58 #endif