Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
exception.hpp
1 /*
2  Title --- exception.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_EXCEPTION_HPP_
23 #define _RPI_HW_EXCEPTION_HPP_
24 
25 #include <stdexcept>
26 
27 #include <rpi-hw/utils.hpp>
28 #include <rpi-hw/utils-inl.hpp>
29 
30 #define exception( x ) exception_class( __FILE__, __LINE__, x )
31 
32 namespace rpihw { // Begin main namespace
33 
34 /*!
35  @class exception_class
36  @brief Runtime exception class.
37 */
38 class exception_class : public std::runtime_error {
39 
40 public:
41 
42  //! Constructor method.
43  exception_class( const char *file, size_t line, const std::string &message ) :
44  std::runtime_error( utils::format( "%s:%lu: \n\t\t", file, line ) + message ) { }
45 };
46 
47 } // End of main namespace
48 
49 #endif /* _RPI_HW_EXCEPTION_HPP_ */
Runtime exception class.
Definition: exception.hpp:38
exception_class(const char *file, size_t line, const std::string &message)
Constructor method.
Definition: exception.hpp:43