+ use dedicated exception classes for expression and parsing errors

This commit is contained in:
wmayer
2015-09-27 23:17:33 +02:00
parent 6b67d4a4e7
commit c114c648fc
4 changed files with 103 additions and 35 deletions

View File

@@ -321,6 +321,40 @@ DivisionByZeroError::DivisionByZeroError(const DivisionByZeroError &inst)
// ---------------------------------------------------------
ExpressionError::ExpressionError(const char * sMessage)
: Exception(sMessage)
{
}
ExpressionError::ExpressionError(const std::string& sMessage)
: Exception(sMessage)
{
}
ExpressionError::ExpressionError(const ExpressionError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
ParserError::ParserError(const char * sMessage)
: Exception(sMessage)
{
}
ParserError::ParserError(const std::string& sMessage)
: Exception(sMessage)
{
}
ParserError::ParserError(const ParserError &inst)
: Exception(inst)
{
}
// ---------------------------------------------------------
#if defined(__GNUC__) && defined (FC_OS_LINUX)
#include <stdexcept>
#include <iostream>

View File

@@ -286,6 +286,39 @@ public:
virtual ~DivisionByZeroError() throw() {}
};
/**
* The ExpressionError can be used to indicate erroneous.input
* to the expression engine.
* @author Werner Mayer
*/
class BaseExport ExpressionError : public Exception
{
public:
/// Construction
ExpressionError(const char * sMessage);
ExpressionError(const std::string& sMessage);
/// Construction
ExpressionError(const ExpressionError &inst);
/// Destruction
virtual ~ExpressionError() throw() {}
};
/**
* The ParserError can be used to indicate the parsing error.
* @author Werner Mayer
*/
class BaseExport ParserError : public Exception
{
public:
/// Construction
ParserError(const char * sMessage);
ParserError(const std::string& sMessage);
/// Construction
ParserError(const ParserError &inst);
/// Destruction
virtual ~ParserError() throw() {}
};
inline void Exception::setMessage(const char * sMessage)
{