Bug 1333564 - [manifestparser] Include manifest path when raising exceptions from the ini parser, r?jmaher
MozReview-Commit-ID: 3Ns9PxVnvy5
--- 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)