USRP Hardware Driver and USRP Manual  Version: 3.15.0.HEAD-0-gaea0e2de
UHD and USRP Manual
exception.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2011 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_UHD_EXCEPTION_HPP
9 #define INCLUDED_UHD_EXCEPTION_HPP
10 
11 #include <uhd/config.hpp>
12 #include <boost/current_function.hpp>
13 #include <stdexcept>
14 #include <string>
15 
33 namespace uhd {
34 
37 struct UHD_API exception : std::runtime_error
38 {
39  exception(const std::string& what);
40  virtual unsigned code(void) const = 0;
41  virtual exception* dynamic_clone(void) const = 0;
42  virtual void dynamic_throw(void) const = 0;
43 };
44 
50 {
51  assertion_error(const std::string& what);
52  virtual unsigned code(void) const;
53  virtual assertion_error* dynamic_clone(void) const;
54  virtual void dynamic_throw(void) const;
55 };
56 
61 {
62  lookup_error(const std::string& what);
63  virtual unsigned code(void) const;
64  virtual lookup_error* dynamic_clone(void) const;
65  virtual void dynamic_throw(void) const;
66 };
67 
71 {
72  index_error(const std::string& what);
73  virtual unsigned code(void) const;
74  virtual index_error* dynamic_clone(void) const;
75  virtual void dynamic_throw(void) const;
76 };
77 
84 {
85  key_error(const std::string& what);
86  virtual unsigned code(void) const;
87  virtual key_error* dynamic_clone(void) const;
88  virtual void dynamic_throw(void) const;
89 };
90 
98 {
99  type_error(const std::string& what);
100  virtual unsigned code(void) const;
101  virtual type_error* dynamic_clone(void) const;
102  virtual void dynamic_throw(void) const;
103 };
104 
110 {
111  value_error(const std::string& what);
112  virtual unsigned code(void) const;
113  virtual value_error* dynamic_clone(void) const;
114  virtual void dynamic_throw(void) const;
115 };
116 
123 {
124  narrowing_error(const std::string& what);
125  virtual unsigned code(void) const;
126  virtual narrowing_error* dynamic_clone(void) const;
127  virtual void dynamic_throw(void) const;
128 };
129 
134 {
135  runtime_error(const std::string& what);
136  virtual unsigned code(void) const;
137  virtual runtime_error* dynamic_clone(void) const;
138  virtual void dynamic_throw(void) const;
139 };
140 
144 {
145  int _code;
146  usb_error(int code, const std::string& what);
147  virtual unsigned code(void) const
148  {
149  return _code;
150  };
151  virtual usb_error* dynamic_clone(void) const;
152  virtual void dynamic_throw(void) const;
153 };
154 
159 {
160  not_implemented_error(const std::string& what);
161  virtual unsigned code(void) const;
162  virtual not_implemented_error* dynamic_clone(void) const;
163  virtual void dynamic_throw(void) const;
164 };
165 
169 {
170  environment_error(const std::string& what);
171  virtual unsigned code(void) const;
172  virtual environment_error* dynamic_clone(void) const;
173  virtual void dynamic_throw(void) const;
174 };
175 
179 {
180  io_error(const std::string& what);
181  virtual unsigned code(void) const;
182  virtual io_error* dynamic_clone(void) const;
183  virtual void dynamic_throw(void) const;
184 };
185 
189 {
190  os_error(const std::string& what);
191  virtual unsigned code(void) const;
192  virtual os_error* dynamic_clone(void) const;
193  virtual void dynamic_throw(void) const;
194 };
195 
199 {
200  system_error(const std::string& what);
201  virtual unsigned code(void) const;
202  virtual system_error* dynamic_clone(void) const;
203  virtual void dynamic_throw(void) const;
204 };
205 
211 {
212  syntax_error(const std::string& what);
213  virtual unsigned code(void) const;
214  virtual syntax_error* dynamic_clone(void) const;
215  virtual void dynamic_throw(void) const;
216 };
217 
224 #define UHD_THROW_SITE_INFO(what) \
225  std::string(std::string(what) + "\n" + " in " + std::string(BOOST_CURRENT_FUNCTION) \
226  + "\n" + " at " + std::string(__FILE__) + ":" \
227  + BOOST_STRINGIZE(__LINE__) + "\n")
228 
233 #define UHD_THROW_INVALID_CODE_PATH() \
234  throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
235 
241 #define UHD_ASSERT_THROW(code) \
242  { \
243  if (not(code)) \
244  throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
245  }
246 
247 } // namespace uhd
248 
249 #endif /* INCLUDED_UHD_EXCEPTION_HPP */
Definition: exception.hpp:37
Definition: exception.hpp:168
Definition: exception.hpp:188
Definition: exception.hpp:158
Definition: exception.hpp:60
Definition: exception.hpp:83
Definition: exception.hpp:133
Definition: exception.hpp:198
int _code
Definition: exception.hpp:145
Definition: exception.hpp:109
Definition: exception.hpp:122
Definition: build_info.hpp:13
Definition: exception.hpp:178
Definition: exception.hpp:70
Definition: exception.hpp:210
Definition: exception.hpp:49
#define UHD_API
Definition: config.h:68
virtual unsigned code(void) const
Definition: exception.hpp:147
Definition: exception.hpp:97
Definition: exception.hpp:143