Skip to content

Commit

Permalink
Fix error message for missing arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed May 2, 2016
1 parent d8fb898 commit ca84038
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/error_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Sass_Import_Entry>* import_stack)
: Base(pstate, msg, import_stack)
{ }
Expand Down
10 changes: 10 additions & 0 deletions src/error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ca84038

Please sign in to comment.