Bug 1044165 - fix BuildReaderError exception printing to cope properly with SyntaxError; r=gps

Some moz.build syntax errors cause the thrown SyntaxError object to not include
an offset field, leading to all sorts of hilarity when we try printing messages
depending on SyntaxError.offset.  Check for this case and simply don't print
the caret if so.
This commit is contained in:
Nathan Froyd 2014-07-25 14:27:44 -04:00
parent 80686692d8
commit 5f9ab2e8fa

View File

@ -566,7 +566,8 @@ class BuildReaderError(Exception):
s.write('on line %d:\n' % inner.lineno)
s.write('\n')
s.write(' %s\n' % inner.text)
s.write((' ' * (inner.offset + 4)) + '^\n')
if inner.offset:
s.write((' ' * (inner.offset + 4)) + '^\n')
s.write('\n')
s.write('Fix the syntax error and try again.\n')
return