Make sublime.expand_variables optionally throw on unknown variable
When parsing project settings, I usually do something like
blah = sublime.expand_variables(blah, self.window.extract_variables())
I’d like this function to throw when an unknown variable is encountered. For instance, ${project_path}
is a well-known useful variable, but when people misspell it, it is seen as an unknown variable and is expanded to the empty string. I would like to detect this case, but it is not possible at the moment, unless I start hacking in my own variable parsing functions. So I propose to change the signature from
expand_variables(value, variables)
to
expand_variables(value, variables, <throw_on_unknown>)
where throw_on_unknown
is a boolean parameter which is False
by default. The thrown exception type should hold the name of the unknown variable as a string.