UHD 003.005.002-0-unknown

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
exception.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2011 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
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 INCLUDED_UHD_EXCEPTION_HPP
19 #define INCLUDED_UHD_EXCEPTION_HPP
20
21 #include <uhd/config.hpp>
22 #include <boost/current_function.hpp>
23 #include <stdexcept>
24 #include <string>
25
43 namespace uhd{
44
45 struct UHD_API exception : std::runtime_error{
46 exception(const std::string &what);
47 virtual unsigned code(void) const = 0;
48 virtual exception *dynamic_clone(void) const = 0;
49 virtual void dynamic_throw(void) const = 0;
50 };
51
52 struct UHD_API assertion_error : exception{
53 assertion_error(const std::string &what);
54 virtual unsigned code(void) const;
55 virtual assertion_error *dynamic_clone(void) const;
56 virtual void dynamic_throw(void) const;
57 };
58
59 struct UHD_API lookup_error : exception{
60 lookup_error(const std::string &what);
61 virtual unsigned code(void) const;
62 virtual lookup_error *dynamic_clone(void) const;
63 virtual void dynamic_throw(void) const;
64 };
65
66 struct UHD_API index_error : lookup_error{
67 index_error(const std::string &what);
68 virtual unsigned code(void) const;
69 virtual index_error *dynamic_clone(void) const;
70 virtual void dynamic_throw(void) const;
71 };
72
73 struct UHD_API key_error : lookup_error{
74 key_error(const std::string &what);
75 virtual unsigned code(void) const;
76 virtual key_error *dynamic_clone(void) const;
77 virtual void dynamic_throw(void) const;
78 };
79
80 struct UHD_API type_error : exception{
81 type_error(const std::string &what);
82 virtual unsigned code(void) const;
83 virtual type_error *dynamic_clone(void) const;
84 virtual void dynamic_throw(void) const;
85 };
86
87 struct UHD_API value_error : exception{
88 value_error(const std::string &what);
89 virtual unsigned code(void) const;
90 virtual value_error *dynamic_clone(void) const;
91 virtual void dynamic_throw(void) const;
92 };
93
94 struct UHD_API runtime_error : exception{
95 runtime_error(const std::string &what);
96 virtual unsigned code(void) const;
97 virtual runtime_error *dynamic_clone(void) const;
98 virtual void dynamic_throw(void) const;
99 };
100
101 struct UHD_API not_implemented_error : runtime_error{
102 not_implemented_error(const std::string &what);
103 virtual unsigned code(void) const;
104 virtual not_implemented_error *dynamic_clone(void) const;
105 virtual void dynamic_throw(void) const;
106 };
107
108 struct UHD_API environment_error : exception{
109 environment_error(const std::string &what);
110 virtual unsigned code(void) const;
111 virtual environment_error *dynamic_clone(void) const;
112 virtual void dynamic_throw(void) const;
113 };
114
115 struct UHD_API io_error : environment_error{
116 io_error(const std::string &what);
117 virtual unsigned code(void) const;
118 virtual io_error *dynamic_clone(void) const;
119 virtual void dynamic_throw(void) const;
120 };
121
122 struct UHD_API os_error : environment_error{
123 os_error(const std::string &what);
124 virtual unsigned code(void) const;
125 virtual os_error *dynamic_clone(void) const;
126 virtual void dynamic_throw(void) const;
127 };
128
129 struct UHD_API system_error : exception{
130 system_error(const std::string &what);
131 virtual unsigned code(void) const;
132 virtual system_error *dynamic_clone(void) const;
133 virtual void dynamic_throw(void) const;
134 };
135
142 #define UHD_THROW_SITE_INFO(what) std::string( \
143 std::string(what) + "\n" + \
144 " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
145 " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
146 )
147
152 #define UHD_THROW_INVALID_CODE_PATH() \
153 throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
154
160 #define UHD_ASSERT_THROW(code) if (not (code)) \
161 throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
162 else void(0)
163
164 } //namespace uhd
165
166 #endif /* INCLUDED_UHD_EXCEPTION_HPP */
uhd::exception
Definition: exception.hpp:45
uhd::environment_error
Definition: exception.hpp:108
uhd::os_error
Definition: exception.hpp:122
uhd::not_implemented_error
Definition: exception.hpp:101
uhd::lookup_error
Definition: exception.hpp:59
uhd::key_error
Definition: exception.hpp:73
uhd::runtime_error
Definition: exception.hpp:94
uhd::system_error
Definition: exception.hpp:129
config.hpp
uhd::value_error
Definition: exception.hpp:87
UHD_API
#define UHD_API
Definition: config.hpp:76
uhd::io_error
Definition: exception.hpp:115
uhd::index_error
Definition: exception.hpp:66
uhd::assertion_error
Definition: exception.hpp:52
uhd::type_error
Definition: exception.hpp:80