Make the message mandatory for NotYetImplemented exception

Reviewers: florijan, buda, mislav.bradac

Reviewed By: mislav.bradac

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D565
This commit is contained in:
Teon Banek 2017-07-18 11:15:08 +02:00
parent 32ed2d7ab8
commit 16d94c8aaf
7 changed files with 23 additions and 24 deletions

View File

@ -150,7 +150,7 @@ antlrcpp::Any CypherMainVisitor::visitClause(CypherParser::ClauseContext *ctx) {
ctx->createIndex()->accept(this).as<CreateIndex *>()); ctx->createIndex()->accept(this).as<CreateIndex *>());
} }
// TODO: implement other clauses. // TODO: implement other clauses.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("clause '{}'", ctx->getText());
return 0; return 0;
} }
@ -295,7 +295,7 @@ antlrcpp::Any CypherMainVisitor::visitProperties(
// better logical plan if we have an information about properties at // better logical plan if we have an information about properties at
// compile time. // compile time.
// TODO: implement other clauses. // TODO: implement other clauses.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("property parameters");
} }
return ctx->mapLiteral()->accept(this); return ctx->mapLiteral()->accept(this);
} }
@ -435,7 +435,7 @@ antlrcpp::Any CypherMainVisitor::visitRelationshipPattern(
} }
if (ctx->relationshipDetail()->rangeLiteral()) { if (ctx->relationshipDetail()->rangeLiteral()) {
// TODO: implement other clauses. // TODO: implement other clauses.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("variable relationship length");
} }
} }
// relationship.has_range = true; // relationship.has_range = true;
@ -623,7 +623,7 @@ antlrcpp::Any CypherMainVisitor::visitExpression5(
if (ctx->expression4().size() > 1U) { if (ctx->expression4().size() > 1U) {
// TODO: implement power operator. In neo4j power is left associative and // TODO: implement power operator. In neo4j power is left associative and
// int^int -> float. // int^int -> float.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("power (^) operator");
} }
return visitChildren(ctx); return visitChildren(ctx);
} }
@ -661,7 +661,7 @@ antlrcpp::Any CypherMainVisitor::visitExpression3a(
} else if (op->CONTAINS()) { } else if (op->CONTAINS()) {
f = NameToFunction(kContains); f = NameToFunction(kContains);
} else { } else {
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("function '{}'", op->getText());
} }
auto expression2 = op->expression3b()->accept(this); auto expression2 = op->expression3b()->accept(this);
std::vector<Expression *> args = {expression, expression2}; std::vector<Expression *> args = {expression, expression2};
@ -739,7 +739,7 @@ antlrcpp::Any CypherMainVisitor::visitAtom(CypherParser::AtomContext *ctx) {
ctx->literal()->accept(this).as<BaseLiteral *>()); ctx->literal()->accept(this).as<BaseLiteral *>());
} else if (ctx->parameter()) { } else if (ctx->parameter()) {
// TODO: implement other clauses. // TODO: implement other clauses.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("atom parameters");
} else if (ctx->parenthesizedExpression()) { } else if (ctx->parenthesizedExpression()) {
return static_cast<Expression *>( return static_cast<Expression *>(
ctx->parenthesizedExpression()->accept(this)); ctx->parenthesizedExpression()->accept(this));
@ -758,7 +758,7 @@ antlrcpp::Any CypherMainVisitor::visitAtom(CypherParser::AtomContext *ctx) {
} }
// TODO: Implement this. We don't support comprehensions, filtering... at // TODO: Implement this. We don't support comprehensions, filtering... at
// the moment. // the moment.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("atom expression '{}'", ctx->getText());
} }
antlrcpp::Any CypherMainVisitor::visitLiteral( antlrcpp::Any CypherMainVisitor::visitLiteral(
@ -782,7 +782,7 @@ antlrcpp::Any CypherMainVisitor::visitLiteral(
ctx->listLiteral()->accept(this).as<std::vector<Expression *>>())); ctx->listLiteral()->accept(this).as<std::vector<Expression *>>()));
} else { } else {
// TODO: Implement map literal. // TODO: Implement map literal.
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("map literal");
} }
return visitChildren(ctx); return visitChildren(ctx);
} }
@ -809,7 +809,7 @@ antlrcpp::Any CypherMainVisitor::visitNumberLiteral(
antlrcpp::Any CypherMainVisitor::visitFunctionInvocation( antlrcpp::Any CypherMainVisitor::visitFunctionInvocation(
CypherParser::FunctionInvocationContext *ctx) { CypherParser::FunctionInvocationContext *ctx) {
if (ctx->DISTINCT()) { if (ctx->DISTINCT()) {
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("DISTINCT function call");
} }
std::string function_name = ctx->functionName()->accept(this); std::string function_name = ctx->functionName()->accept(this);
std::vector<Expression *> expressions; std::vector<Expression *> expressions;

View File

@ -55,7 +55,7 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor {
case kGeTokenId: case kGeTokenId:
return storage_.Create<GreaterEqualOperator>(e1, e2); return storage_.Create<GreaterEqualOperator>(e1, e2);
default: default:
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("binary operator");
} }
} }
@ -68,7 +68,7 @@ class CypherMainVisitor : public antlropencypher::CypherBaseVisitor {
case kUnaryMinusTokenId: case kUnaryMinusTokenId:
return storage_.Create<UnaryMinusOperator>(e); return storage_.Create<UnaryMinusOperator>(e);
default: default:
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("unary operator");
} }
} }

View File

@ -250,8 +250,7 @@ class ExpressionEvaluator : public TreeVisitor<TypedValue> {
property_lookup.property_); property_lookup.property_);
case TypedValue::Type::Map: case TypedValue::Type::Map:
// TODO implement me // TODO implement me
throw utils::NotYetImplemented( throw utils::NotYetImplemented("property lookup on map");
"Not yet implemented property lookup on map");
default: default:
throw QueryRuntimeException( throw QueryRuntimeException(
"Expected Node, Edge or Map for property lookup"); "Expected Node, Edge or Map for property lookup");

View File

@ -986,7 +986,7 @@ void ReconstructTypedValue(TypedValue &value) {
break; break;
case TypedValue::Type::Path: case TypedValue::Type::Path:
// TODO implement path reconstruct? // TODO implement path reconstruct?
throw utils::NotYetImplemented("Path reconstruction not yet supported"); throw utils::NotYetImplemented("path reconstruction");
default: default:
break; break;
} }

View File

@ -1109,8 +1109,7 @@ std::unique_ptr<LogicalOperator> RuleBasedPlanner::Plan(
input_op = new plan::CreateIndex(create_index->label_, input_op = new plan::CreateIndex(create_index->label_,
create_index->property_); create_index->property_);
} else { } else {
throw utils::NotYetImplemented( throw utils::NotYetImplemented("clause conversion to operator(s)");
"Encountered a clause which cannot be converted to operator(s)");
} }
} }
} }

View File

@ -505,7 +505,7 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) {
return true; return true;
} }
case TypedValue::Type::Path: case TypedValue::Type::Path:
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("equality for TypedValue::Type::Path");
default: default:
permanent_fail("Unhandled comparison for types"); permanent_fail("Unhandled comparison for types");
} }
@ -780,7 +780,7 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const {
case TypedValue::Type::Edge: case TypedValue::Type::Edge:
return value.Value<EdgeAccessor>().temporary_id(); return value.Value<EdgeAccessor>().temporary_id();
case TypedValue::Type::Path: case TypedValue::Type::Path:
throw utils::NotYetImplemented(); throw utils::NotYetImplemented("hashing for TypedValue::Type::Path");
break; break;
} }
permanent_fail("Unhandled TypedValue.type() in hash function"); permanent_fail("Unhandled TypedValue.type() in hash function");

View File

@ -182,14 +182,15 @@ class StacktraceException : public std::exception {
/** /**
* @brief Raise this exception for functionality which is yet to be implemented. * @brief Raise this exception for functionality which is yet to be implemented.
*/ */
class NotYetImplemented final : public StacktraceException { class NotYetImplemented final : public BasicException {
public: public:
using StacktraceException::StacktraceException; explicit NotYetImplemented(const std::string &what) noexcept
: BasicException("Not yet implemented: " + what) {}
/** template <class... Args>
* @brief Construct with the default "Not yet implemented!" message. explicit NotYetImplemented(const std::string &format,
*/ Args &&... args) noexcept
NotYetImplemented() noexcept : StacktraceException("Not yet implemented!") {} : NotYetImplemented(fmt::format(format, std::forward<Args>(args)...)) {}
}; };
} // namespace utils } // namespace utils