Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error message for missing arguments #2067

Merged
merged 1 commit into from
May 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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