USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-ga1b5c4ae
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 
35  struct UHD_API exception : std::runtime_error{
36  exception(const std::string &what);
37  virtual unsigned code(void) const = 0;
38  virtual exception *dynamic_clone(void) const = 0;
39  virtual void dynamic_throw(void) const = 0;
40  };
41 
43  assertion_error(const std::string &what);
44  virtual unsigned code(void) const;
45  virtual assertion_error *dynamic_clone(void) const;
46  virtual void dynamic_throw(void) const;
47  };
48 
50  lookup_error(const std::string &what);
51  virtual unsigned code(void) const;
52  virtual lookup_error *dynamic_clone(void) const;
53  virtual void dynamic_throw(void) const;
54  };
55 
57  index_error(const std::string &what);
58  virtual unsigned code(void) const;
59  virtual index_error *dynamic_clone(void) const;
60  virtual void dynamic_throw(void) const;
61  };
62 
64  key_error(const std::string &what);
65  virtual unsigned code(void) const;
66  virtual key_error *dynamic_clone(void) const;
67  virtual void dynamic_throw(void) const;
68  };
69 
71  type_error(const std::string &what);
72  virtual unsigned code(void) const;
73  virtual type_error *dynamic_clone(void) const;
74  virtual void dynamic_throw(void) const;
75  };
76 
78  value_error(const std::string &what);
79  virtual unsigned code(void) const;
80  virtual value_error *dynamic_clone(void) const;
81  virtual void dynamic_throw(void) const;
82  };
83 
85  narrowing_error(const std::string &what);
86  virtual unsigned code(void) const;
87  virtual narrowing_error *dynamic_clone(void) const;
88  virtual void dynamic_throw(void) const;
89  };
90 
92  runtime_error(const std::string &what);
93  virtual unsigned code(void) const;
94  virtual runtime_error *dynamic_clone(void) const;
95  virtual void dynamic_throw(void) const;
96  };
97 
99  int _code;
100  usb_error(int code, const std::string &what);
101  virtual unsigned code(void) const { return _code; };
102  virtual usb_error *dynamic_clone(void) const;
103  virtual void dynamic_throw(void) const;
104  };
105 
107  not_implemented_error(const std::string &what);
108  virtual unsigned code(void) const;
109  virtual not_implemented_error *dynamic_clone(void) const;
110  virtual void dynamic_throw(void) const;
111  };
112 
114  environment_error(const std::string &what);
115  virtual unsigned code(void) const;
116  virtual environment_error *dynamic_clone(void) const;
117  virtual void dynamic_throw(void) const;
118  };
119 
121  io_error(const std::string &what);
122  virtual unsigned code(void) const;
123  virtual io_error *dynamic_clone(void) const;
124  virtual void dynamic_throw(void) const;
125  };
126 
128  os_error(const std::string &what);
129  virtual unsigned code(void) const;
130  virtual os_error *dynamic_clone(void) const;
131  virtual void dynamic_throw(void) const;
132  };
133 
135  system_error(const std::string &what);
136  virtual unsigned code(void) const;
137  virtual system_error *dynamic_clone(void) const;
138  virtual void dynamic_throw(void) const;
139  };
140 
142  syntax_error(const std::string &what);
143  virtual unsigned code(void) const;
144  virtual syntax_error *dynamic_clone(void) const;
145  virtual void dynamic_throw(void) const;
146  };
147 
154  #define UHD_THROW_SITE_INFO(what) std::string( \
155  std::string(what) + "\n" + \
156  " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
157  " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
158  )
159 
164  #define UHD_THROW_INVALID_CODE_PATH() \
165  throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
166 
172  #define UHD_ASSERT_THROW(code) {if (not (code)) \
173  throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
174  }
175 
176 } //namespace uhd
177 
178 #endif /* INCLUDED_UHD_EXCEPTION_HPP */
Definition: exception.hpp:35
Definition: exception.hpp:113
Definition: exception.hpp:127
Definition: exception.hpp:106
Definition: exception.hpp:49
Definition: exception.hpp:63
Definition: exception.hpp:91
Definition: exception.hpp:134
int _code
Definition: exception.hpp:99
Definition: exception.hpp:77
Definition: exception.hpp:84
Definition: build_info.hpp:14
Definition: exception.hpp:120
Definition: exception.hpp:56
Definition: exception.hpp:141
Definition: exception.hpp:42
#define UHD_API
Definition: config.h:63
virtual unsigned code(void) const
Definition: exception.hpp:101
Definition: exception.hpp:70
Definition: exception.hpp:98