Bug 1162826 - Properly display full moz.build processing errors when empty KeyError or ValueError are thrown. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 08 May 2015 11:06:39 +0900
changeset 243433 18bd273a594ba40900af8a3843282bc3ae450b1b
parent 243432 3b3465149f3886f3bade4b5892741e902560c6fc
child 243434 3804df2cb8767956ca3f788589678aa012fd6ef2
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherderautoland@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1162826
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1162826 - Properly display full moz.build processing errors when empty KeyError or ValueError are thrown. r=mshal
python/mozbuild/mozbuild/frontend/reader.py
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -676,17 +676,17 @@ class BuildReaderError(Exception):
         if isinstance(inner, KeyError):
             self._print_keyerror(inner, s)
         elif isinstance(inner, ValueError):
             self._print_valueerror(inner, s)
         else:
             self._print_exception(inner, s)
 
     def _print_keyerror(self, inner, s):
-        if inner.args[0] not in ('global_ns', 'local_ns'):
+        if not inner.args or inner.args[0] not in ('global_ns', 'local_ns'):
             self._print_exception(inner, s)
             return
 
         if inner.args[0] == 'global_ns':
             import difflib
 
             verb = None
             if inner.args[1] == 'get_unknown':
@@ -735,17 +735,17 @@ class BuildReaderError(Exception):
         s.write('local variable:\n')
         s.write('\n')
         s.write('    %s\n' % inner.args[2])
         s.write('\n')
         s.write('Please change the file to not reference undefined ')
         s.write('variables and try again.\n')
 
     def _print_valueerror(self, inner, s):
-        if inner.args[0] not in ('global_ns', 'local_ns'):
+        if not inner.args or inner.args[0] not in ('global_ns', 'local_ns'):
             self._print_exception(inner, s)
             return
 
         assert inner.args[1] == 'set_type'
 
         s.write('The underlying problem is an attempt to write an illegal ')
         s.write('value to a special variable.\n')
         s.write('\n')