Something went wrong on our end
-
Martin Beseda authored
ENH + FIX: Added missing 'throw' command to exception macros. Added new THROW_OUT_OF_RANGE_ERROR macro.
Martin Beseda authoredENH + FIX: Added missing 'throw' command to exception macros. Added new THROW_OUT_OF_RANGE_ERROR macro.
exceptions.h 1.10 KiB
//
// Created by martin on 9/17/18.
//
#ifndef LIB4NEURO_EXCEPTIONS_H
#define LIB4NEURO_EXCEPTIONS_H
#include <stdexcept>
#include <boost/type_index.hpp> //TODO Can Boost be included here?
#ifdef L4N_DEBUG
#define ERR_MSG(msg) std::string(boost::typeindex::type_id_with_cvr<decltype(*this)>().pretty_name()) + "::" + __func__ + "(): " + msg + " (" +__FILE__ + ":" + std::to_string(__LINE__) + ")"
#else
#define ERR_MSG(msg) std::string(boost::typeindex::type_id_with_cvr<decltype(*this)>().pretty_name()) + "::" + __func__ + "(): " + msg
#endif // L4N_DEBUG
#define THROW_RUNTIME_ERROR(msg) throw std::runtime_error(ERR_MSG(msg)) // Errors, that can't be detected by looking at the code
#define THROW_LOGIC_ERROR(msg) throw std::logic_error(ERR_MSG(msg)) // Errors, that can be detected by looking at the code
#define THROW_INVALID_ARGUMENT_ERROR(msg) throw std::invalid_argument(ERR_MSG(msg))
#define THROW_NOT_IMPLEMENTED_ERROR(msg) throw std::logic_error(ERR_MSG("This function is not implemented." + msg))
#define THROW_OUT_OF_RANGE_ERROR(msg) throw std::out_of_range(ERR_MSG(msg))
#endif //LIB4NEURO_EXCEPTIONS_H