Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2598)

Unified Diff: build/android/gyp/generate_v14_compatible_resources.py

Issue 661433005: Clearer error message when parsing Android XML resource fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/generate_v14_compatible_resources.py
diff --git a/build/android/gyp/generate_v14_compatible_resources.py b/build/android/gyp/generate_v14_compatible_resources.py
index 1961622b7afb26ffb84af9c1999233d1e77f487a..79a2d5f94aec279a4727aca577ed368d327cf98f 100755
--- a/build/android/gyp/generate_v14_compatible_resources.py
+++ b/build/android/gyp/generate_v14_compatible_resources.py
@@ -65,6 +65,16 @@ def IterateXmlElements(node):
yield child_node_element
+def ParseAndReportErrors(filename):
+ try:
+ return minidom.parse(filename)
+ except Exception:
+ import traceback
+ traceback.print_exc()
Kibeom Kim (inactive) 2014/10/30 07:07:39 Just a question: it looks this is a common practic
Kibeom Kim (inactive) 2014/10/30 07:10:44 Though, having the most important message at the l
+ sys.stderr.write('Failed to parse XML file: %s\n' % filename)
+ sys.exit(1)
+
+
def AssertNotDeprecatedAttribute(name, value, filename):
"""Raises an exception if the given attribute is deprecated."""
msg = None
@@ -100,7 +110,7 @@ def HasStyleResource(dom):
def ErrorIfStyleResourceExistsInDir(input_dir):
"""If a style resource is in input_dir, raises an exception."""
for input_filename in build_utils.FindInDirectory(input_dir, '*.xml'):
- dom = minidom.parse(input_filename)
+ dom = ParseAndReportErrors(input_filename)
if HasStyleResource(dom):
raise Exception('error: style file ' + input_filename +
' should be under ' + input_dir +
@@ -177,7 +187,7 @@ def GenerateV14LayoutResource(input_filename, output_v14_filename,
don't do anything. If not, write the generated resource to
output_v14_filename, and copy the original resource to output_v17_filename.
"""
- dom = minidom.parse(input_filename)
+ dom = ParseAndReportErrors(input_filename)
is_modified = GenerateV14LayoutResourceDom(dom, input_filename)
if is_modified:
@@ -196,7 +206,7 @@ def GenerateV14StyleResource(input_filename, output_v14_filename):
It's mostly a simple replacement, s/Start/Left s/End/Right,
on the attribute names.
"""
- dom = minidom.parse(input_filename)
+ dom = ParseAndReportErrors(input_filename)
GenerateV14StyleResourceDom(dom, input_filename)
# Write the generated resource.
@@ -231,7 +241,7 @@ def VerifyV14ResourcesInDir(input_dir, resource_type):
' Pre-v17 resources should not include it because it '
'can cause crashes on certain devices. Please refer to '
'http://crbug.com/243952 for the details.')
- dom = minidom.parse(input_filename)
+ dom = ParseAndReportErrors(input_filename)
if resource_type in ('layout', 'xml'):
if GenerateV14LayoutResourceDom(dom, input_filename, False):
raise Exception(exception_message)
@@ -244,7 +254,7 @@ def AssertNoDeprecatedAttributesInDir(input_dir, resource_type):
"""Raises an exception if resources in input_dir have deprecated attributes,
e.g., paddingLeft, paddingRight"""
for input_filename in build_utils.FindInDirectory(input_dir, '*.xml'):
- dom = minidom.parse(input_filename)
+ dom = ParseAndReportErrors(input_filename)
if resource_type in ('layout', 'xml'):
GenerateV14LayoutResourceDom(dom, input_filename)
elif resource_type == 'values':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698