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