From e1672fa7eedb00a977c39b7e80bb18521493b524 Mon Sep 17 00:00:00 2001 From: Balint Seeber Date: Mon, 27 Jul 2015 14:15:29 -0700 Subject: uhd: Added usb_error exception type --- host/include/uhd/exception.hpp | 8 ++++++++ host/lib/exception.cpp | 5 +++++ 2 files changed, 13 insertions(+) (limited to 'host') diff --git a/host/include/uhd/exception.hpp b/host/include/uhd/exception.hpp index 69e902fd5..a21106166 100644 --- a/host/include/uhd/exception.hpp +++ b/host/include/uhd/exception.hpp @@ -98,6 +98,14 @@ namespace uhd{ virtual void dynamic_throw(void) const; }; + struct UHD_API usb_error : runtime_error{ + int _code; + usb_error(int code, const std::string &what); + virtual unsigned code(void) const { return _code; }; + virtual usb_error *dynamic_clone(void) const; + virtual void dynamic_throw(void) const; + }; + struct UHD_API not_implemented_error : runtime_error{ not_implemented_error(const std::string &what); virtual unsigned code(void) const; diff --git a/host/lib/exception.cpp b/host/lib/exception.cpp index ea056bd3b..a9e36fd15 100644 --- a/host/lib/exception.cpp +++ b/host/lib/exception.cpp @@ -43,3 +43,8 @@ make_exception_impl("EnvironmentError", environment_error, exception) make_exception_impl("IOError", io_error, environment_error) make_exception_impl("OSError", os_error, environment_error) make_exception_impl("SystemError", system_error, exception) + +usb_error::usb_error(int code, const std::string &what): + runtime_error(str(boost::format("%s %d: %s") % "USBError" % code % what)), _code(code) {} +usb_error *usb_error::dynamic_clone(void) const{return new usb_error(*this);} \ +void usb_error::dynamic_throw(void) const{throw *this;} -- cgit v1.2.3