All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
exception.hpp
Go to the documentation of this file.
//
// 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
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef INCLUDED_UHD_EXCEPTION_HPP
#define INCLUDED_UHD_EXCEPTION_HPP
#include <uhd/config.hpp>
#include <boost/current_function.hpp>
#include <stdexcept>
#include <string>
namespace uhd{
struct UHD_API exception : std::runtime_error{
exception(const std::string &what);
virtual unsigned code(void) const = 0;
virtual exception *dynamic_clone(void) const = 0;
virtual void dynamic_throw(void) const = 0;
};
struct UHD_API assertion_error : exception{
assertion_error(const std::string &what);
virtual unsigned code(void) const;
virtual assertion_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API lookup_error : exception{
lookup_error(const std::string &what);
virtual unsigned code(void) const;
virtual lookup_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API index_error : lookup_error{
index_error(const std::string &what);
virtual unsigned code(void) const;
virtual index_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API key_error : lookup_error{
key_error(const std::string &what);
virtual unsigned code(void) const;
virtual key_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API type_error : exception{
type_error(const std::string &what);
virtual unsigned code(void) const;
virtual type_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API value_error : exception{
value_error(const std::string &what);
virtual unsigned code(void) const;
virtual value_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API runtime_error : exception{
runtime_error(const std::string &what);
virtual unsigned code(void) const;
virtual runtime_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;
virtual not_implemented_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API environment_error : exception{
environment_error(const std::string &what);
virtual unsigned code(void) const;
virtual environment_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API io_error : environment_error{
io_error(const std::string &what);
virtual unsigned code(void) const;
virtual io_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API os_error : environment_error{
os_error(const std::string &what);
virtual unsigned code(void) const;
virtual os_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
struct UHD_API system_error : exception{
system_error(const std::string &what);
virtual unsigned code(void) const;
virtual system_error *dynamic_clone(void) const;
virtual void dynamic_throw(void) const;
};
#define UHD_THROW_SITE_INFO(what) std::string( \
std::string(what) + "\n" + \
" in " + std::string(BOOST_CURRENT_FUNCTION) + "\n" + \
" at " + std::string(__FILE__) + ":" + BOOST_STRINGIZE(__LINE__) + "\n" \
)
#define UHD_THROW_INVALID_CODE_PATH() \
throw uhd::system_error(UHD_THROW_SITE_INFO("invalid code path"))
#define UHD_ASSERT_THROW(code) if (not (code)) \
throw uhd::assertion_error(UHD_THROW_SITE_INFO(#code)); \
else void(0)
} //namespace uhd
#endif /* INCLUDED_UHD_EXCEPTION_HPP */