UHD  003.001.002
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_UTILS_EXCEPTION_HPP
19 #define INCLUDED_UHD_UTILS_EXCEPTION_HPP
20 
21 #include <uhd/config.hpp>
22 #include <boost/current_function.hpp>
23 #include <stdexcept>
24 #include <string>
25 
36 namespace uhd{
37 
38  struct UHD_API exception : std::runtime_error{
39  exception(const std::string &what);
40  virtual unsigned code(void) const = 0;
41  };
42 
44  assertion_error(const std::string &what);
45  virtual unsigned code(void) const;
46  };
47 
49  lookup_error(const std::string &what);
50  virtual unsigned code(void) const;
51  };
52 
54  index_error(const std::string &what);
55  virtual unsigned code(void) const;
56  };
57 
59  key_error(const std::string &what);
60  virtual unsigned code(void) const;
61  };
62 
64  type_error(const std::string &what);
65  virtual unsigned code(void) const;
66  };
67 
69  value_error(const std::string &what);
70  virtual unsigned code(void) const;
71  };
72 
74  runtime_error(const std::string &what);
75  virtual unsigned code(void) const;
76  };
77 
79  not_implemented_error(const std::string &what);
80  virtual unsigned code(void) const;
81  };
82 
84  environment_error(const std::string &what);
85  virtual unsigned code(void) const;
86  };
87 
89  io_error(const std::string &what);
90  virtual unsigned code(void) const;
91  };
92 
94  os_error(const std::string &what);
95  virtual unsigned code(void) const;
96  };
97 
99  system_error(const std::string &what);
100  virtual unsigned code(void) const;
101  };
102 
109  #define UHD_THROW_SITE_INFO(what) std::string( \
110  std::string(what) + "\n" + \
111  " in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
112  " at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
113  )
114 
119  #define UHD_THROW_INVALID_CODE_PATH() \
120  throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
121 
127  #define UHD_ASSERT_THROW(code) if (not (code)) \
128  throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
129  else void(0)
130 
131 } //namespace uhd
132 
133 #endif /* INCLUDED_UHD_UTILS_EXCEPTION_HPP */
Definition: exception.hpp:38
Definition: exception.hpp:83
Definition: exception.hpp:93
Definition: exception.hpp:78
Definition: exception.hpp:48
Definition: exception.hpp:58
Definition: exception.hpp:73
Definition: exception.hpp:98
Definition: exception.hpp:68
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: exception.hpp:88
Definition: exception.hpp:53
Definition: exception.hpp:43
Definition: exception.hpp:63