CBOE Emulator  1.0
exceptions.hpp
1 // Exceptions that can be thrown by the application.
2 // Copyright 2020 Christian Kauten
3 //
4 // Author: Christian Kauten (kautenja@auburn.edu)
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
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 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef EXCEPTIONS_HPP
19 #define EXCEPTIONS_HPP
20 
21 #include <exception>
22 #include <string>
23 
25 class Exception: public std::exception {
26  protected:
28  std::string msg_;
29 
30  public:
35  explicit Exception(const char* message) : msg_(message) { }
36 
39  explicit Exception(const std::string& message) : msg_(message) { }
40 
42  virtual ~Exception() throw () { }
43 
48  virtual const char* what() const throw () { return msg_.c_str(); }
49 };
50 
51 #endif // EXCEPTIONS_HPP
Exception
An exception class.
Definition: exceptions.hpp:25
Exception::msg_
std::string msg_
the error message.
Definition: exceptions.hpp:28
Exception::Exception
Exception(const std::string &message)
Constructor (C++ STL strings).
Definition: exceptions.hpp:39
Exception::Exception
Exception(const char *message)
Constructor (C strings).
Definition: exceptions.hpp:35
Exception::what
virtual const char * what() const
Returns a pointer to the (constant) error description.
Definition: exceptions.hpp:48
Exception::~Exception
virtual ~Exception()
Destroy this exception.
Definition: exceptions.hpp:42