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

View File

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

View File

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

View File

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

View File

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

View File

@ -505,7 +505,7 @@ TypedValue operator==(const TypedValue &a, const TypedValue &b) {
return true;
}
case TypedValue::Type::Path:
throw utils::NotYetImplemented();
throw utils::NotYetImplemented("equality for TypedValue::Type::Path");
default:
permanent_fail("Unhandled comparison for types");
}
@ -780,7 +780,7 @@ size_t TypedValue::Hash::operator()(const TypedValue &value) const {
case TypedValue::Type::Edge:
return value.Value<EdgeAccessor>().temporary_id();
case TypedValue::Type::Path:
throw utils::NotYetImplemented();
throw utils::NotYetImplemented("hashing for TypedValue::Type::Path");
break;
}
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.
*/
class NotYetImplemented final : public StacktraceException {
class NotYetImplemented final : public BasicException {
public:
using StacktraceException::StacktraceException;
explicit NotYetImplemented(const std::string &what) noexcept
: BasicException("Not yet implemented: " + what) {}
/**
* @brief Construct with the default "Not yet implemented!" message.
*/
NotYetImplemented() noexcept : StacktraceException("Not yet implemented!") {}
template <class... Args>
explicit NotYetImplemented(const std::string &format,
Args &&... args) noexcept
: NotYetImplemented(fmt::format(format, std::forward<Args>(args)...)) {}
};
} // namespace utils