Prepared exceptions to have different types.

This commit is contained in:
2017-06-17 22:06:18 +02:00
parent da2a3eefa4
commit 7ead2277e8
16 changed files with 38 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
#ifndef __PDDL_PARSE__PARSER_EXCEPTION_H
#define __PDDL_PARSE__PARSER_EXCEPTION_H
#ifndef __PDDL_PARSE__EXCEPTION_H
#define __PDDL_PARSE__EXCEPTION_H
#include <exception>
#include <string>
@@ -11,39 +11,39 @@ namespace pddl
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// ParserException
// Exception
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class ParserException: public std::exception
class Exception: public std::exception
{
public:
explicit ParserException()
: ParserException("unspecified parser error")
explicit Exception()
: Exception("unspecified parser error")
{
}
explicit ParserException(const char *message)
: ParserException(static_cast<std::string>(message))
explicit Exception(const char *message)
: Exception(static_cast<std::string>(message))
{
}
explicit ParserException(const std::string &message)
explicit Exception(const std::string &message)
: m_message{message}
{
}
explicit ParserException(const tokenize::Location &location)
: ParserException(location, "unspecified parser error")
explicit Exception(const tokenize::Location &location)
: Exception(location, "unspecified parser error")
{
}
explicit ParserException(const tokenize::Location &location, const char *message)
: ParserException(location, static_cast<std::string>(message))
explicit Exception(const tokenize::Location &location, const char *message)
: Exception(location, static_cast<std::string>(message))
{
}
explicit ParserException(const tokenize::Location &location, const std::string &message)
explicit Exception(const tokenize::Location &location, const std::string &message)
: m_location{location},
m_message{message},
// TODO: refactor
@@ -52,7 +52,7 @@ class ParserException: public std::exception
{
}
~ParserException() noexcept = default;
~Exception() noexcept = default;
const char *what() const throw()
{
@@ -77,6 +77,14 @@ class ParserException: public std::exception
////////////////////////////////////////////////////////////////////////////////////////////////////
class ParserException : public Exception
{
public:
using Exception::Exception;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
#endif

View File

@@ -3,7 +3,7 @@
#include <pddlparse/AST.h>
#include <pddlparse/Context.h>
#include <pddlparse/ParserException.h>
#include <pddlparse/Exception.h>
#include <pddlparse/detail/ASTContext.h>
#include <pddlparse/detail/VariableStack.h>
#include <pddlparse/detail/parsing/VariableDeclaration.h>