USRP Hardware Driver and USRP Manual  Version: 4.0.0.0-304-g65fbf053c
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 #pragma once
9 
10 #include <uhd/config.hpp>
11 #include <boost/current_function.hpp>
12 #include <stdexcept>
13 #include <string>
14 
32 namespace uhd {
33 
36 struct UHD_API exception : std::runtime_error
37 {
38  exception(const std::string& what);
39  virtual unsigned code(void) const = 0;
40  virtual exception* dynamic_clone(void) const = 0;
41  virtual void dynamic_throw(void) const = 0;
42 };
43 
49 {
50  assertion_error(const std::string& what);
51  virtual unsigned code(void) const;
52  virtual assertion_error* dynamic_clone(void) const;
53  virtual void dynamic_throw(void) const;
54 };
55 
60 {
61  lookup_error(const std::string& what);
62  virtual unsigned code(void) const;
63  virtual lookup_error* dynamic_clone(void) const;
64  virtual void dynamic_throw(void) const;
65 };
66 
70 {
71  index_error(const std::string& what);
72  virtual unsigned code(void) const;
73  virtual index_error* dynamic_clone(void) const;
74  virtual void dynamic_throw(void) const;
75 };
76 
83 {
84  key_error(const std::string& what);
85  virtual unsigned code(void) const;
86  virtual key_error* dynamic_clone(void) const;
87  virtual void dynamic_throw(void) const;
88 };
89 
97 {
98  type_error(const std::string& what);
99  virtual unsigned code(void) const;
100  virtual type_error* dynamic_clone(void) const;
101  virtual void dynamic_throw(void) const;
102 };
103 
109 {
110  value_error(const std::string& what);
111  virtual unsigned code(void) const;
112  virtual value_error* dynamic_clone(void) const;
113  virtual void dynamic_throw(void) const;
114 };
115 
122 {
123  narrowing_error(const std::string& what);
124  virtual unsigned code(void) const;
125  virtual narrowing_error* dynamic_clone(void) const;
126  virtual void dynamic_throw(void) const;
127 };
128 
133 {
134  runtime_error(const std::string& what);
135  virtual unsigned code(void) const;
136  virtual runtime_error* dynamic_clone(void) const;
137  virtual void dynamic_throw(void) const;
138 };
139 
143 {
144  int _code;
145  usb_error(int code, const std::string& what);
146  virtual unsigned code(void) const
147  {
148  return _code;
149  };
150  virtual usb_error* dynamic_clone(void) const;
151  virtual void dynamic_throw(void) const;
152 };
153 
158 {
159  not_implemented_error(const std::string& what);
160  virtual unsigned code(void) const;
161  virtual not_implemented_error* dynamic_clone(void) const;
162  virtual void dynamic_throw(void) const;
163 };
164 
169 {
170  access_error(const std::string& what);
171  virtual unsigned code(void) const;
172  virtual access_error* dynamic_clone(void) const;
173  virtual void dynamic_throw(void) const;
174 };
175 
179 {
180  environment_error(const std::string& what);
181  virtual unsigned code(void) const;
182  virtual environment_error* dynamic_clone(void) const;
183  virtual void dynamic_throw(void) const;
184 };
185 
189 {
190  io_error(const std::string& what);
191  virtual unsigned code(void) const;
192  virtual io_error* dynamic_clone(void) const;
193  virtual void dynamic_throw(void) const;
194 };
195 
199 {
200  os_error(const std::string& what);
201  virtual unsigned code(void) const;
202  virtual os_error* dynamic_clone(void) const;
203  virtual void dynamic_throw(void) const;
204 };
205 
209 {
210  system_error(const std::string& what);
211  virtual unsigned code(void) const;
212  virtual system_error* dynamic_clone(void) const;
213  virtual void dynamic_throw(void) const;
214 };
215 
221 {
222  syntax_error(const std::string& what);
223  virtual unsigned code(void) const;
224  virtual syntax_error* dynamic_clone(void) const;
225  virtual void dynamic_throw(void) const;
226 };
227 
231 {
232  rfnoc_error(const std::string& what);
233  virtual unsigned code(void) const;
234  virtual rfnoc_error* dynamic_clone(void) const;
235  virtual void dynamic_throw(void) const;
236 };
237 
241 {
242  op_failed(const std::string& what);
243  virtual unsigned code(void) const;
244  virtual op_failed* dynamic_clone(void) const;
245  virtual void dynamic_throw(void) const;
246 };
247 
252 {
253  op_timeout(const std::string& what);
254  virtual unsigned code(void) const;
255  virtual op_timeout* dynamic_clone(void) const;
256  virtual void dynamic_throw(void) const;
257 };
258 
262 {
263  op_seqerr(const std::string& what);
264  virtual unsigned code(void) const;
265  virtual op_seqerr* dynamic_clone(void) const;
266  virtual void dynamic_throw(void) const;
267 };
268 
272 {
273  op_timerr(const std::string& what);
274  virtual unsigned code(void) const;
275  virtual op_timerr* dynamic_clone(void) const;
276  virtual void dynamic_throw(void) const;
277 };
278 
282 {
283  resolve_error(const std::string& what);
284  virtual unsigned code(void) const;
285  virtual resolve_error* dynamic_clone(void) const;
286  virtual void dynamic_throw(void) const;
287 };
288 
292 {
293  routing_error(const std::string& what);
294  virtual unsigned code(void) const;
295  virtual routing_error* dynamic_clone(void) const;
296  virtual void dynamic_throw(void) const;
297 };
298 
305 #define UHD_THROW_SITE_INFO(what) \
306  std::string(std::string(what) + "\n" + " in " + std::string(BOOST_CURRENT_FUNCTION) \
307  + "\n" + " at " + std::string(__FILE__) + ":" \
308  + BOOST_STRINGIZE(__LINE__) + "\n")
309 
314 #define UHD_THROW_INVALID_CODE_PATH() \
315  throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
316 
322 #define UHD_ASSERT_THROW(code) \
323  { \
324  if (not(code)) \
325  throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
326  }
327 
328 } // namespace uhd
Definition: exception.hpp:36
Definition: exception.hpp:178
Definition: exception.hpp:198
Definition: exception.hpp:157
Definition: exception.hpp:261
Definition: exception.hpp:59
Definition: exception.hpp:82
Definition: exception.hpp:230
Definition: exception.hpp:132
Definition: exception.hpp:208
Definition: exception.hpp:291
int _code
Definition: exception.hpp:144
Definition: exception.hpp:271
Definition: exception.hpp:108
Definition: exception.hpp:121
Definition: build_info.hpp:12
Definition: exception.hpp:168
Definition: exception.hpp:188
Definition: exception.hpp:240
Definition: exception.hpp:69
Definition: exception.hpp:220
Definition: exception.hpp:48
#define UHD_API
Definition: config.h:67
Definition: exception.hpp:281
Definition: exception.hpp:251
virtual unsigned code(void) const
Definition: exception.hpp:146
Definition: exception.hpp:96
Definition: exception.hpp:142