diff options
author | German M. Bravo <german.mb@deipi.com> | 2013-10-06 11:49:57 -0500 |
---|---|---|
committer | German M. Bravo <german.mb@deipi.com> | 2013-10-06 11:49:57 -0500 |
commit | 173c248c80eda7b569709ea83e5b0df616932028 (patch) | |
tree | 6829e3bfdba8b8bdc6705f8a93b9c541bb73cba8 | |
parent | 906dfcff02defaa63a06b3c0acf6969b0f508d4f (diff) | |
download | pyscss-173c248c80eda7b569709ea83e5b0df616932028.tar.gz |
Interactive mode prints Sass errors and Added SyntaxError exception for Undefined variables
-rw-r--r-- | scss/expression.py | 4 | ||||
-rw-r--r-- | scss/tool.py | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/scss/expression.py b/scss/expression.py index cab058d..cacd8ec 100644 --- a/scss/expression.py +++ b/scss/expression.py @@ -74,7 +74,7 @@ class Calculator(object): v = self.namespace.variable(n) except KeyError: if config.FATAL_UNDEFINED: - raise + raise SyntaxError("Undefined variable: '%s'." % n) else: if config.VERBOSITY > 1: log.error("Undefined variable '%s'", n, extra={'stack': True}) @@ -352,7 +352,7 @@ class Variable(Expression): value = calculator.namespace.variable(self.name) except KeyError: if config.FATAL_UNDEFINED: - raise + raise SyntaxError("Undefined variable: '%s'." % self.name) else: if config.VERBOSITY > 1: log.error("Undefined variable '%s'", self.name, extra={'stack': True}) diff --git a/scss/tool.py b/scss/tool.py index c9753c0..f1bced0 100644 --- a/scss/tool.py +++ b/scss/tool.py @@ -17,6 +17,7 @@ from scss.rule import SassRule from scss.rule import UnparsedBlock from scss.expression import Calculator from scss.scss_meta import BUILD_INFO +from scss.errors import SassEvaluationError try: raw_input @@ -392,7 +393,10 @@ class SassRepl(object): continue # TODO respect compress? - yield(self.calculator.calculate(s).render()) + try: + yield(self.calculator.calculate(s).render()) + except SassEvaluationError as e: + print("%s" % e, file=sys.stderr) if __name__ == "__main__": |