Skip to content

Commit 34bcd3f

Browse files
committed
Merge pull request #2067 from mgreter/errmsg/missing-fn-argument
Fix error message for missing arguments
2 parents e330689 + ca84038 commit 34bcd3f

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/bind.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,7 @@ namespace Sass {
275275
}
276276
else {
277277
// param is unbound and has no default value -- error
278-
std::stringstream msg;
279-
msg << "required parameter " << leftover->name()
280-
<< " is missing in call to " << callee;
281-
error(msg.str(), as->pstate());
278+
throw Exception::MissingArgument(as->pstate(), name, leftover->name(), type);
282279
}
283280
}
284281
}

src/error_handling.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,19 @@ namespace Sass {
3535
: Base(pstate), fn(fn), arg(arg), type(type), value(value)
3636
{
3737
msg = arg + ": \"";
38-
msg += value->to_string(Sass_Inspect_Options());
38+
if (value) msg += value->to_string(Sass_Inspect_Options());
3939
msg += "\" is not a " + type;
4040
msg += " for `" + fn + "'";
4141
}
4242

43+
MissingArgument::MissingArgument(ParserState pstate, std::string fn, std::string arg, std::string fntype)
44+
: Base(pstate), fn(fn), arg(arg), fntype(fntype)
45+
{
46+
msg = fntype + " " + fn;
47+
msg += " is missing argument ";
48+
msg += arg + ".";
49+
}
50+
4351
InvalidSyntax::InvalidSyntax(ParserState pstate, std::string msg, std::vector<Sass_Import_Entry>* import_stack)
4452
: Base(pstate, msg, import_stack)
4553
{ }

src/error_handling.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ namespace Sass {
4545
virtual ~InvalidParent() throw() {};
4646
};
4747

48+
class MissingArgument : public Base {
49+
protected:
50+
std::string fn;
51+
std::string arg;
52+
std::string fntype;
53+
public:
54+
MissingArgument(ParserState pstate, std::string fn, std::string arg, std::string fntype);
55+
virtual ~MissingArgument() throw() {};
56+
};
57+
4858
class InvalidArgumentType : public Base {
4959
protected:
5060
std::string fn;

0 commit comments

Comments
 (0)