2017-03-15 21:08:58 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-19 21:52:20 +08:00
|
|
|
#include "utils/exceptions.hpp"
|
2017-03-15 21:08:58 +08:00
|
|
|
|
2017-03-22 16:42:43 +08:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2017-03-15 21:08:58 +08:00
|
|
|
namespace query {
|
|
|
|
|
2017-04-12 20:38:22 +08:00
|
|
|
/** @brief Base class of all query language related exceptions.
|
|
|
|
*/
|
2017-04-19 21:52:20 +08:00
|
|
|
class QueryException : public utils::BasicException {
|
|
|
|
using utils::BasicException::BasicException;
|
2017-04-12 20:38:22 +08:00
|
|
|
};
|
|
|
|
|
2017-06-21 22:10:52 +08:00
|
|
|
class LexingException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
LexingException() : QueryException("") {}
|
|
|
|
};
|
|
|
|
|
2017-04-12 20:38:22 +08:00
|
|
|
class SyntaxException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
SyntaxException() : QueryException("") {}
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Figure out what information to put in exception.
|
|
|
|
// Error reporting is tricky since we get stripped query and position of error
|
|
|
|
// in original query is not same as position of error in stripped query. Most
|
|
|
|
// correct approach would be to do semantic analysis with original query even
|
|
|
|
// for already hashed queries, but that has obvious performance issues. Other
|
|
|
|
// approach would be to report some of the semantic errors in runtime of the
|
|
|
|
// query and only report line numbers of semantic errors (not position in the
|
|
|
|
// line) if multiple line strings are not allowed by grammar. We could also
|
|
|
|
// print whole line that contains error instead of specifying line number.
|
2017-04-12 20:38:22 +08:00
|
|
|
class SemanticException : public QueryException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-12 20:38:22 +08:00
|
|
|
using QueryException::QueryException;
|
|
|
|
SemanticException() : QueryException("") {}
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-03-17 16:57:20 +08:00
|
|
|
class UnboundVariableError : public SemanticException {
|
|
|
|
public:
|
|
|
|
UnboundVariableError(const std::string &name)
|
|
|
|
: SemanticException("Unbound variable: " + name) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class RedeclareVariableError : public SemanticException {
|
|
|
|
public:
|
2017-03-22 16:42:43 +08:00
|
|
|
RedeclareVariableError(const std::string &name)
|
2017-03-17 16:57:20 +08:00
|
|
|
: SemanticException("Redeclaring variable: " + name) {}
|
|
|
|
};
|
|
|
|
|
2017-03-22 16:42:43 +08:00
|
|
|
class TypeMismatchError : public SemanticException {
|
|
|
|
public:
|
|
|
|
TypeMismatchError(const std::string &name, const std::string &datum,
|
|
|
|
const std::string &expected)
|
|
|
|
: SemanticException(fmt::format(
|
|
|
|
"Type mismatch: '{}' already defined as '{}', but expected '{}'.",
|
|
|
|
name, datum, expected)) {}
|
|
|
|
};
|
|
|
|
|
2017-07-14 19:58:25 +08:00
|
|
|
class HintedAbortError : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
HintedAbortError() : QueryException("") {}
|
|
|
|
};
|
|
|
|
|
2017-07-20 00:14:59 +08:00
|
|
|
class UnprovidedParameterError : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
UnprovidedParameterError() : QueryException("") {}
|
|
|
|
};
|
|
|
|
|
2017-03-27 19:09:14 +08:00
|
|
|
/**
|
|
|
|
* An exception for an illegal operation that can not be detected
|
|
|
|
* before the query starts executing over data.
|
|
|
|
*/
|
2017-04-12 20:38:22 +08:00
|
|
|
class QueryRuntimeException : public QueryException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-13 19:45:46 +08:00
|
|
|
using QueryException::QueryException;
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-04-13 19:45:46 +08:00
|
|
|
// TODO: Move this elsewhere, it has no place in query.
|
2017-04-19 21:52:20 +08:00
|
|
|
class DecoderException : public utils::StacktraceException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-19 21:52:20 +08:00
|
|
|
using utils::StacktraceException::StacktraceException;
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-04-19 21:52:20 +08:00
|
|
|
class PlanCompilationException : public utils::StacktraceException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-19 21:52:20 +08:00
|
|
|
using utils::StacktraceException::StacktraceException;
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-04-19 21:52:20 +08:00
|
|
|
class PlanExecutionException : public utils::StacktraceException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-19 21:52:20 +08:00
|
|
|
using utils::StacktraceException::StacktraceException;
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-04-13 19:45:46 +08:00
|
|
|
} // namespace query
|