summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-04 09:46:02 +0000
committerJosh Blum <josh@joshknows.com>2010-05-04 09:46:02 +0000
commit77b9aaf5bdb9c50a2456f1aa5e3498ec228ab679 (patch)
tree0192aed78f868048ae871c0ec5c079c1cbbd8e70 /host
parent8f21adbed40db490bec8ead6b8d50d2b3d1a4136 (diff)
downloaduhd-77b9aaf5bdb9c50a2456f1aa5e3498ec228ab679.tar.gz
uhd-77b9aaf5bdb9c50a2456f1aa5e3498ec228ab679.tar.bz2
uhd-77b9aaf5bdb9c50a2456f1aa5e3498ec228ab679.zip
fix files before pull
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/utils/assert.hpp32
-rw-r--r--host/include/uhd/utils/props.hpp17
-rw-r--r--host/include/uhd/utils/safe_main.hpp5
-rw-r--r--host/test/error_test.cpp17
4 files changed, 26 insertions, 45 deletions
diff --git a/host/include/uhd/utils/assert.hpp b/host/include/uhd/utils/assert.hpp
index 577050aff..2f0ed4ff1 100644
--- a/host/include/uhd/utils/assert.hpp
+++ b/host/include/uhd/utils/assert.hpp
@@ -19,37 +19,24 @@
#define INCLUDED_UHD_UTILS_ASSERT_HPP
#include <uhd/config.hpp>
+#include <uhd/utils/exception.hpp>
#include <uhd/utils/algorithm.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/exception/info.hpp>
#include <stdexcept>
#include <string>
-#ifndef BOOST_THROW_EXCEPTION
- #include <boost/exception/exception.hpp>
- #include <boost/current_function.hpp>
- #define BOOST_THROW_EXCEPTION(x)\
- ::boost::throw_exception( ::boost::enable_error_info(x) <<\
- ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
- ::boost::throw_file(__FILE__) <<\
- ::boost::throw_line((int)__LINE__) )
-
-#endif
-
namespace uhd{
//! The exception to throw when assertions fail
- struct UHD_API assert_error : virtual std::exception, virtual boost::exception{};
-
- //! The assertion info, the code that failed
- typedef boost::error_info<struct tag_assert_info, std::string> assert_info;
+ struct UHD_API assert_error : std::runtime_error{
+ assert_error(const std::string &what);
+ };
//! Throw an assert error with throw-site information
#define UHD_ASSERT_THROW(_x) if (not (_x)) \
- BOOST_THROW_EXCEPTION(uhd::assert_error() << uhd::assert_info(#_x))
+ throw uhd::assert_error(UHD_THROW_SITE_INFO("assertion failed: " + std::string(#_x)))
/*!
* Check that an element is found in a container.
@@ -74,13 +61,14 @@ namespace uhd{
if (i++ > 0) possible_values += ", ";
possible_values += boost::lexical_cast<std::string>(v);
}
- boost::throw_exception(uhd::assert_error() << assert_info(str(boost::format(
- "Error: %s is not a valid %s. "
- "Possible values are: [%s]."
+ throw uhd::assert_error(str(boost::format(
+ "assertion failed:\n"
+ " %s is not a valid %s.\n"
+ " possible values are: [%s].\n"
)
% boost::lexical_cast<std::string>(value)
% what % possible_values
- )));
+ ));
}
}//namespace uhd
diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp
index 6c40c32e0..f376d2612 100644
--- a/host/include/uhd/utils/props.hpp
+++ b/host/include/uhd/utils/props.hpp
@@ -20,17 +20,12 @@
#include <uhd/config.hpp>
#include <uhd/wax.hpp>
+#include <uhd/utils/exception.hpp>
#include <boost/tuple/tuple.hpp>
-#include <boost/throw_exception.hpp>
-#include <boost/exception/info.hpp>
#include <stdexcept>
#include <vector>
#include <string>
-#ifndef BOOST_THROW_EXCEPTION
-#define BOOST_THROW_EXCEPTION(x) throw std::runtime_error("")
-#endif
-
namespace uhd{
//! The type for a vector of property names
@@ -63,25 +58,19 @@ namespace uhd{
const std::string &name = ""
);
- //! The exception to throw for property errors
- struct UHD_API prop_error : virtual std::exception, virtual boost::exception{};
-
- //! The property error info (verbose or message)
- typedef boost::error_info<struct tag_prop_info, std::string> prop_info;
-
/*!
* Throw when getting a not-implemented or write-only property.
* Throw-site information will be included with this error.
*/
#define UHD_THROW_PROP_GET_ERROR() \
- BOOST_THROW_EXCEPTION(uhd::prop_error() << uhd::prop_info("cannot get this property"))
+ throw std::runtime_error(UHD_THROW_SITE_INFO("cannot get this property"))
/*!
* Throw when setting a not-implemented or read-only property.
* Throw-site information will be included with this error.
*/
#define UHD_THROW_PROP_SET_ERROR() \
- BOOST_THROW_EXCEPTION(uhd::prop_error() << uhd::prop_info("cannot set this property"))
+ throw std::runtime_error(UHD_THROW_SITE_INFO("cannot set this property"))
} //namespace uhd
diff --git a/host/include/uhd/utils/safe_main.hpp b/host/include/uhd/utils/safe_main.hpp
index 39d2282cd..b682aa540 100644
--- a/host/include/uhd/utils/safe_main.hpp
+++ b/host/include/uhd/utils/safe_main.hpp
@@ -19,7 +19,6 @@
#define INCLUDED_UHD_UTILS_SAFE_MAIN_HPP
#include <uhd/config.hpp>
-//#include <boost/exception/diagnostic_information.hpp>
#include <iostream>
#include <stdexcept>
@@ -34,9 +33,7 @@
int main(int argc, char *argv[]){ \
try { \
return _main(argc, argv); \
- } /*catch(const boost::exception &e){ \
- std::cerr << "Error: " << boost::diagnostic_information(e) << std::endl; \
- }*/ catch(const std::exception &e) { \
+ } catch(const std::exception &e) { \
std::cerr << "Error: " << e.what() << std::endl; \
} catch(...) { \
std::cerr << "Error: unknown exception" << std::endl; \
diff --git a/host/test/error_test.cpp b/host/test/error_test.cpp
index 3f2479f99..c76a15ab7 100644
--- a/host/test/error_test.cpp
+++ b/host/test/error_test.cpp
@@ -17,7 +17,6 @@
#include <boost/test/unit_test.hpp>
#include <uhd/utils/assert.hpp>
-//#include <boost/exception/diagnostic_information.hpp>
#include <vector>
#include <iostream>
@@ -30,12 +29,20 @@ BOOST_AUTO_TEST_CASE(test_assert_has){
//verify the std::has utility
BOOST_CHECK(std::has(vec, 2));
BOOST_CHECK(not std::has(vec, 1));
-/*
+
std::cout << "The output of the assert_has error:" << std::endl;
try{
uhd::assert_has(vec, 1, "prime");
- }catch(const boost::exception &e){
- std::cout << boost::diagnostic_information(e) << std::endl;
+ }catch(const std::exception &e){
+ std::cout << e.what() << std::endl;
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_assert_throw){
+ std::cout << "The output of the assert throw error:" << std::endl;
+ try{
+ UHD_ASSERT_THROW(2 + 2 == 5);
+ }catch(const std::exception &e){
+ std::cout << e.what() << std::endl;
}
-*/
}