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