Bug 1333564 - [manifestparser] Include manifest path when raising exceptions from the ini parser, r?jmaher draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 25 Jan 2017 15:51:06 -0500
changeset 466827 d3856c1db2ecba3bda1cc91f269ea6e91c1231f6
parent 466826 7eca443a73dff58c39dddc932a423fa8aa086b03
child 543527 52a9bf681d5a009a233837b6a0d11f9f4bcb29e2
push id43008
push userahalberstadt@mozilla.com
push dateThu, 26 Jan 2017 17:34:22 +0000
reviewersjmaher
bugs1333564
milestone54.0a1
Bug 1333564 - [manifestparser] Include manifest path when raising exceptions from the ini parser, r?jmaher MozReview-Commit-ID: 3Ns9PxVnvy5
testing/mozbase/manifestparser/manifestparser/ini.py
--- a/testing/mozbase/manifestparser/manifestparser/ini.py
+++ b/testing/mozbase/manifestparser/manifestparser/ini.py
@@ -84,17 +84,18 @@ def read_ini(fp, variables=None, default
 
             section_names.add(section)
             current_section = {}
             sections.append((section, current_section))
             continue
 
         # if there aren't any sections yet, something bad happen
         if not section_names:
-            raise Exception('No sections found')
+            raise Exception("Error parsing manifest file '%s', line %s: No sections found" %
+                            (getattr(fp, 'name', 'unknown'), linenum))
 
         # (key, value) pair
         for separator in separators:
             if separator in stripped:
                 key, value = stripped.split(separator, 1)
                 key = key.strip()
                 value = value.strip()
 
@@ -108,22 +109,18 @@ def read_ini(fp, variables=None, default
                 break
         else:
             # continuation line ?
             if line[0].isspace() and key:
                 value = '%s%s%s' % (value, os.linesep, stripped)
                 current_section[key] = value
             else:
                 # something bad happened!
-                if hasattr(fp, 'name'):
-                    filename = fp.name
-                else:
-                    filename = 'unknown'
                 raise Exception("Error parsing manifest file '%s', line %s" %
-                                (filename, linenum))
+                                (getattr(fp, 'name', 'unknown'), linenum))
 
     # server-root is a special os path declared relative to the manifest file.
     # inheritance demands we expand it as absolute
     if 'server-root' in variables:
         root = os.path.join(os.path.dirname(fp.name),
                             variables['server-root'])
         variables['server-root'] = os.path.abspath(root)