/** * AMDA_exception.hh * * Created on: 16 oct. 2012 * Author: AKKA IS */ #ifndef AMDA_EXCEPTION_HH_ #define AMDA_EXCEPTION_HH_ #include #include "log4cxx/logger.h" #include "DicError.hh" #include "boost/exception/all.hpp" /** * facility to throw an exception with log */ #define ERROR_EXCEPTION(msg) { LOG4CXX_ERROR( gLogger, msg); \ std::stringstream oss; oss << msg; \ BOOST_THROW_EXCEPTION( exception() << ex_msg(oss.str())); \ } namespace AMDA { /** * @brief Store, error number return by AMDA application, @see DicError.hh */ typedef boost::error_info errno_code; /** * @brief definition exception AMDA */ struct AMDA_exception: virtual std::exception, virtual boost::exception { }; typedef boost::error_info errno_code; typedef boost::error_info ex_msg; inline std::string traitException(int &result, AMDA::AMDA_exception & e) { if (int const* res = boost::get_error_info(e)) { result = *res; } else { result = AMDA_ERROR_UNKNOWN; } return boost::diagnostic_information(e);//error of parser Eclipse because e may be an boost or an std exception } } /* namespace AMDA */ #endif /* AMDA_EXCEPTION_HH_ */