From ca84038236ad90fcea65e7cadcaac2fdae639ab4 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Mon, 2 May 2016 23:44:03 +0200 Subject: [PATCH] Fix error message for missing arguments --- src/bind.cpp | 5 +---- src/error_handling.cpp | 10 +++++++++- src/error_handling.hpp | 10 ++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/bind.cpp b/src/bind.cpp index 5f77fe8e19..bb509e85dd 100644 --- a/src/bind.cpp +++ b/src/bind.cpp @@ -275,10 +275,7 @@ namespace Sass { } else { // param is unbound and has no default value -- error - std::stringstream msg; - msg << "required parameter " << leftover->name() - << " is missing in call to " << callee; - error(msg.str(), as->pstate()); + throw Exception::MissingArgument(as->pstate(), name, leftover->name(), type); } } } diff --git a/src/error_handling.cpp b/src/error_handling.cpp index 05f35b2f78..afe98fc7c8 100644 --- a/src/error_handling.cpp +++ b/src/error_handling.cpp @@ -35,11 +35,19 @@ namespace Sass { : Base(pstate), fn(fn), arg(arg), type(type), value(value) { msg = arg + ": \""; - msg += value->to_string(Sass_Inspect_Options()); + if (value) msg += value->to_string(Sass_Inspect_Options()); msg += "\" is not a " + type; msg += " for `" + fn + "'"; } + MissingArgument::MissingArgument(ParserState pstate, std::string fn, std::string arg, std::string fntype) + : Base(pstate), fn(fn), arg(arg), fntype(fntype) + { + msg = fntype + " " + fn; + msg += " is missing argument "; + msg += arg + "."; + } + InvalidSyntax::InvalidSyntax(ParserState pstate, std::string msg, std::vector* import_stack) : Base(pstate, msg, import_stack) { } diff --git a/src/error_handling.hpp b/src/error_handling.hpp index 16cc29543b..abaf4dda56 100644 --- a/src/error_handling.hpp +++ b/src/error_handling.hpp @@ -45,6 +45,16 @@ namespace Sass { virtual ~InvalidParent() throw() {}; }; + class MissingArgument : public Base { + protected: + std::string fn; + std::string arg; + std::string fntype; + public: + MissingArgument(ParserState pstate, std::string fn, std::string arg, std::string fntype); + virtual ~MissingArgument() throw() {}; + }; + class InvalidArgumentType : public Base { protected: std::string fn;