diff options
Diffstat (limited to 'host/lib/utils')
-rw-r--r-- | host/lib/utils/images.cpp | 4 | ||||
-rw-r--r-- | host/lib/utils/load_modules.cpp | 10 | ||||
-rw-r--r-- | host/lib/utils/paths.cpp | 1 | ||||
-rw-r--r-- | host/lib/utils/thread_priority.cpp | 14 | ||||
-rw-r--r-- | host/lib/utils/warning.cpp | 4 |
5 files changed, 16 insertions, 17 deletions
diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp index 395e542c1..3756f035a 100644 --- a/host/lib/utils/images.cpp +++ b/host/lib/utils/images.cpp @@ -16,9 +16,9 @@ // #include <uhd/utils/images.hpp> +#include <uhd/exception.hpp> #include <boost/foreach.hpp> #include <boost/filesystem.hpp> -#include <stdexcept> #include <vector> namespace fs = boost::filesystem; @@ -36,5 +36,5 @@ std::string uhd::find_image_path(const std::string &image_name){ fs::path image_path = path / image_name; if (fs::exists(image_path)) return image_path.file_string(); } - throw std::runtime_error("Could not find path for image: " + image_name); + throw uhd::io_error("Could not find path for image: " + image_name); } diff --git a/host/lib/utils/load_modules.cpp b/host/lib/utils/load_modules.cpp index fa9b22438..ad39960bb 100644 --- a/host/lib/utils/load_modules.cpp +++ b/host/lib/utils/load_modules.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -16,11 +16,11 @@ // #include <uhd/utils/static.hpp> +#include <uhd/exception.hpp> #include <boost/format.hpp> #include <boost/foreach.hpp> #include <boost/filesystem.hpp> #include <iostream> -#include <stdexcept> #include <string> #include <vector> @@ -33,7 +33,7 @@ namespace fs = boost::filesystem; #include <dlfcn.h> static void load_module(const std::string &file_name){ if (dlopen(file_name.c_str(), RTLD_LAZY) == NULL){ - throw std::runtime_error(str( + throw uhd::os_error(str( boost::format("dlopen failed to load \"%s\"") % file_name )); } @@ -45,7 +45,7 @@ static void load_module(const std::string &file_name){ #include <windows.h> static void load_module(const std::string &file_name){ if (LoadLibrary(file_name.c_str()) == NULL){ - throw std::runtime_error(str( + throw uhd::os_error(str( boost::format("LoadLibrary failed to load \"%s\"") % file_name )); } @@ -55,7 +55,7 @@ static void load_module(const std::string &file_name){ #ifdef HAVE_LOAD_MODULES_DUMMY static void load_module(const std::string &file_name){ - throw std::runtime_error(str( + throw uhd::not_implemented_error(str( boost::format("Module loading not supported: Cannot load \"%s\"") % file_name )); } diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 8d604d849..329695873 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -22,7 +22,6 @@ #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/bind.hpp> -#include <stdexcept> #include <string> #include <vector> diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index 18f372ec0..bd34055e8 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ #include <uhd/utils/thread_priority.hpp> #include <uhd/utils/warning.hpp> +#include <uhd/exception.hpp> #include <boost/format.hpp> -#include <stdexcept> #include <iostream> bool uhd::set_thread_priority_safe(float priority, bool realtime){ @@ -59,13 +59,13 @@ static void check_priority_range(float priority){ //get the priority bounds for the selected policy int min_pri = sched_get_priority_min(policy); int max_pri = sched_get_priority_max(policy); - if (min_pri == -1 or max_pri == -1) throw std::runtime_error("error in sched_get_priority_min/max"); + if (min_pri == -1 or max_pri == -1) throw uhd::os_error("error in sched_get_priority_min/max"); //set the new priority and policy sched_param sp; sp.sched_priority = int(priority*(max_pri - min_pri)) + min_pri; int ret = pthread_setschedparam(pthread_self(), policy, &sp); - if (ret != 0) throw std::runtime_error("error in pthread_setschedparam"); + if (ret != 0) throw uhd::os_error("error in pthread_setschedparam"); } #endif /* HAVE_PTHREAD_SETSCHEDPARAM */ @@ -81,7 +81,7 @@ static void check_priority_range(float priority){ //set the priority class on the process int pri_class = (realtime)? REALTIME_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS; if (SetPriorityClass(GetCurrentProcess(), pri_class) == 0) - throw std::runtime_error("error in SetPriorityClass"); + throw uhd::os_error("error in SetPriorityClass"); //scale the priority value to the constants int priorities[] = { @@ -92,7 +92,7 @@ static void check_priority_range(float priority){ //set the thread priority on the thread if (SetThreadPriority(GetCurrentThread(), priorities[pri_index]) == 0) - throw std::runtime_error("error in SetThreadPriority"); + throw uhd::os_error("error in SetThreadPriority"); } #endif /* HAVE_WIN_SETTHREADPRIORITY */ @@ -101,7 +101,7 @@ static void check_priority_range(float priority){ **********************************************************************/ #ifdef HAVE_LOAD_MODULES_DUMMY void uhd::set_thread_priority(float, bool){ - throw std::runtime_error("set thread priority not implemented"); + throw uhd::not_implemented_error("set thread priority not implemented"); } #endif /* HAVE_LOAD_MODULES_DUMMY */ diff --git a/host/lib/utils/warning.cpp b/host/lib/utils/warning.cpp index bc4c79b6e..6a94a0a2c 100644 --- a/host/lib/utils/warning.cpp +++ b/host/lib/utils/warning.cpp @@ -16,12 +16,12 @@ // #include <uhd/utils/warning.hpp> +#include <uhd/exception.hpp> #include <boost/tokenizer.hpp> #include <uhd/utils/static.hpp> #include <uhd/types/dict.hpp> #include <boost/foreach.hpp> #include <sstream> -#include <stdexcept> #include <iostream> #include <vector> @@ -76,7 +76,7 @@ void warning::register_handler( } warning::handler_t warning::unregister_handler(const std::string &name){ - if (not get_registry().has_key(name)) throw std::runtime_error( + if (not get_registry().has_key(name)) throw uhd::key_error( "The warning registry does not have a handler registered to " + name ); return get_registry().pop(name); |