USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
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  not_implemented_error(const std::string &what);
103  virtual unsigned code(void) const;
104  virtual not_implemented_error *dynamic_clone(void) const;
105  virtual void dynamic_throw(void) const;
106  };
107 
109  environment_error(const std::string &what);
110  virtual unsigned code(void) const;
111  virtual environment_error *dynamic_clone(void) const;
112  virtual void dynamic_throw(void) const;
113  };
114 
116  io_error(const std::string &what);
117  virtual unsigned code(void) const;
118  virtual io_error *dynamic_clone(void) const;
119  virtual void dynamic_throw(void) const;
120  };
121 
123  os_error(const std::string &what);
124  virtual unsigned code(void) const;
125  virtual os_error *dynamic_clone(void) const;
126  virtual void dynamic_throw(void) const;
127  };
128 
130  system_error(const std::string &what);
131  virtual unsigned code(void) const;
132  virtual system_error *dynamic_clone(void) const;
133  virtual void dynamic_throw(void) const;
134  };
135 
142  #define UHD_THROW_SITE_INFO(what) std::string( \
143  std::string(what) + "\n" + \
144  " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
145  " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
146  )
147 
152  #define UHD_THROW_INVALID_CODE_PATH() \
153  throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
154 
160  #define UHD_ASSERT_THROW(code) {if (not (code)) \
161  throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
162  }
163 
164 } //namespace uhd
165 
166 #endif /* INCLUDED_UHD_EXCEPTION_HPP */
Definition: exception.hpp:45
Definition: exception.hpp:108
Definition: exception.hpp:122
Definition: exception.hpp:101
Definition: exception.hpp:59
Definition: exception.hpp:73
Definition: exception.hpp:94
Definition: exception.hpp:129
Definition: exception.hpp:87
#define UHD_API
Definition: config.hpp:79
Definition: convert.hpp:28
Definition: exception.hpp:115
Definition: exception.hpp:66
Definition: exception.hpp:52
Definition: exception.hpp:80