summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerman M. Bravo <german.mb@deipi.com>2013-08-18 12:23:10 -0500
committerGerman M. Bravo <german.mb@deipi.com>2013-08-18 12:23:10 -0500
commita1d950f5d38fa05f62d15418df05ee8e6b6f2687 (patch)
tree9d9ece2f3c85a69ff28f00a95e1cb64baa82f5c4
parent8ec0d7f2caaef2f3a504b5537da09f1016c54b34 (diff)
downloadpyscss-a1d950f5d38fa05f62d15418df05ee8e6b6f2687.tar.gz
Improved errors returned from the scanner
-rw-r--r--scss/_native.py4
-rw-r--r--scss/src/scanner.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/scss/_native.py b/scss/_native.py
index 4ae875b..7dafe54 100644
--- a/scss/_native.py
+++ b/scss/_native.py
@@ -209,9 +209,9 @@ class Scanner(object):
# If we didn't find anything, raise an error
if best_pat is None:
- msg = "Bad Token"
+ msg = "Bad token found"
if restrict:
- msg = "Trying to find one of " + ", ".join(restrict)
+ msg = "Bad token found while trying to find one of the restricted tokens: %s" % (", ".join(repr(r) for r in restrict))
raise SyntaxError("SyntaxError[@ char %s: %s]" % (repr(self.pos), msg))
# If we found something that isn't to be ignored, return it
diff --git a/scss/src/scanner.c b/scss/src/scanner.c
index ca74ba7..988810a 100644
--- a/scss/src/scanner.c
+++ b/scss/src/scanner.c
@@ -217,7 +217,7 @@ _Scanner_scan(Scanner *self, Pattern *restrictions, int restrictions_sz)
/* If we didn't find anything, raise an error */
if (best_token.regex == NULL) {
if (restrictions_sz) {
- sprintf(self->exc, "SyntaxError[@ char %d: %s found while trying to find one of the restricted tokens: ", self->pos, (regex == NULL) ? "???" : repr(regex->tok));
+ sprintf(self->exc, "SyntaxError[@ char %d: Bad token found while trying to find one of the restricted tokens: ", self->pos);
aux = self->exc + strlen(self->exc);
for (k=0; k<restrictions_sz; k++) {
len = strlen(restrictions[k].tok);
@@ -231,7 +231,7 @@ _Scanner_scan(Scanner *self, Pattern *restrictions, int restrictions_sz)
sprintf(aux, "]");
return SCANNER_EXC_RESTRICTED;
}
- sprintf(self->exc, "SyntaxError[@ char %d: Bad token: %s]", self->pos, (regex == NULL) ? "???" : repr(regex->tok));
+ sprintf(self->exc, "SyntaxError[@ char %d: Bad token found]", self->pos);
return SCANNER_EXC_BAD_TOKEN;
}
/* If we found something that isn't to be ignored, return it */