#ifndef __JLANG__JTHROW__ #define __JLANG__JTHROW__ #include #include "JLang/JException.hh" /** * \file * * Exception handling. * \author mdejong */ namespace JLANG {} namespace JPP { using namespace JLANG; } namespace JLANG { /** * Auxiliary base class for controling the throwing of exceptions. * The template class refers to the throwing object. */ template class JThrow { protected: static bool do_throw; //!< throw option public: /** * Enable/disable throw option. * * \param option true enable; false disable */ static void Throw(const bool option) { do_throw = option; } /** * Throw exception or return error. * * \param error exception * \param value return code * \return return code */ static int Throw(const JException& error, const int value = -1) { using namespace std; if (do_throw) { throw error; } cerr << error.what() << endl; return value; } }; /** * Set default throw option to true. */ template bool JThrow::do_throw = true; } #endif