USRP Hardware Driver and USRP Manual  Version: 004.000.000.HEAD-0-g8773fb2c
UHD and USRP Manual
exception.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2011 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_EXCEPTION_HPP
19 #define INCLUDED_UHD_EXCEPTION_HPP
20 
21 #include <uhd/config.hpp>
22 #include <boost/current_function.hpp>
23 #include <stdexcept>
24 #include <string>
25 
43 namespace uhd{
44 
45  struct UHD_API exception : std::runtime_error{
46  exception(const std::string &what);
47  virtual unsigned code(void) const = 0;
48  virtual exception *dynamic_clone(void) const = 0;
49  virtual void dynamic_throw(void) const = 0;
50  };
51 
53  assertion_error(const std::string &what);
54  virtual unsigned code(void) const;
55  virtual assertion_error *dynamic_clone(void) const;
56  virtual void dynamic_throw(void) const;
57  };
58 
60  lookup_error(const std::string &what);
61  virtual unsigned code(void) const;
62  virtual lookup_error *dynamic_clone(void) const;
63  virtual void dynamic_throw(void) const;
64  };
65 
67  index_error(const std::string &what);
68  virtual unsigned code(void) const;
69  virtual index_error *dynamic_clone(void) const;
70  virtual void dynamic_throw(void) const;
71  };
72 
74  key_error(const std::string &what);
75  virtual unsigned code(void) const;
76  virtual key_error *dynamic_clone(void) const;
77  virtual void dynamic_throw(void) const;
78  };
79 
81  type_error(const std::string &what);
82  virtual unsigned code(void) const;
83  virtual type_error *dynamic_clone(void) const;
84  virtual void dynamic_throw(void) const;
85  };
86 
88  value_error(const std::string &what);
89  virtual unsigned code(void) const;
90  virtual value_error *dynamic_clone(void) const;
91  virtual void dynamic_throw(void) const;
92  };
93 
95  runtime_error(const std::string &what);
96  virtual unsigned code(void) const;
97  virtual runtime_error *dynamic_clone(void) const;
98  virtual void dynamic_throw(void) const;
99  };
100 
102  int _code;
103  usb_error(int code, const std::string &what);
104  virtual unsigned code(void) const { return _code; };
105  virtual usb_error *dynamic_clone(void) const;
106  virtual void dynamic_throw(void) const;
107  };
108 
110  not_implemented_error(const std::string &what);
111  virtual unsigned code(void) const;
112  virtual not_implemented_error *dynamic_clone(void) const;
113  virtual void dynamic_throw(void) const;
114  };
115 
117  environment_error(const std::string &what);
118  virtual unsigned code(void) const;
119  virtual environment_error *dynamic_clone(void) const;
120  virtual void dynamic_throw(void) const;
121  };
122 
124  io_error(const std::string &what);
125  virtual unsigned code(void) const;
126  virtual io_error *dynamic_clone(void) const;
127  virtual void dynamic_throw(void) const;
128  };
129 
131  os_error(const std::string &what);
132  virtual unsigned code(void) const;
133  virtual os_error *dynamic_clone(void) const;
134  virtual void dynamic_throw(void) const;
135  };
136 
138  system_error(const std::string &what);
139  virtual unsigned code(void) const;
140  virtual system_error *dynamic_clone(void) const;
141  virtual void dynamic_throw(void) const;
142  };
143 
145  syntax_error(const std::string &what);
146  virtual unsigned code(void) const;
147  virtual syntax_error *dynamic_clone(void) const;
148  virtual void dynamic_throw(void) const;
149  };
150 
157  #define UHD_THROW_SITE_INFO(what) std::string( \
158  std::string(what) + "\n" + \
159  " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
160  " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
161  )
162 
167  #define UHD_THROW_INVALID_CODE_PATH() \
168  throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
169 
175  #define UHD_ASSERT_THROW(code) {if (not (code)) \
176  throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
177  }
178 
179 } //namespace uhd
180 
181 #endif /* INCLUDED_UHD_EXCEPTION_HPP */
Definition: exception.hpp:45
Definition: exception.hpp:116
Definition: exception.hpp:130
Definition: exception.hpp:109
Definition: exception.hpp:59
Definition: exception.hpp:73
Definition: exception.hpp:94
Definition: exception.hpp:137
int _code
Definition: exception.hpp:102
Definition: exception.hpp:87
Definition: build_info.hpp:25
Definition: exception.hpp:123
Definition: exception.hpp:66
Definition: exception.hpp:144
Definition: exception.hpp:52
#define UHD_API
Definition: config.h:73
virtual unsigned code(void) const
Definition: exception.hpp:104
Definition: exception.hpp:80
Definition: exception.hpp:101