Commit 8697dfcf authored by martiniss's avatar martiniss Committed by Commit bot

Fix bot_update to correctly handle exceptions

If an exception occurs during a try block which prevents a step from actually executing, then the finally block's attempt to access step.active_result will fail, and the original exception will be hidden behind a new exception from the recipe engine. This CL changes this behavior so that the original exception will always fire.

Review-Url: https://codereview.chromium.org/2175103002
parent aa71dd9f
......@@ -231,20 +231,25 @@ class BotUpdateApi(recipe_api.RecipeApi):
name += ' - %s' % suffix
# Ah hah! Now that everything is in place, lets run bot_update!
step_result = None
try:
# 87 and 88 are the 'patch failure' codes for patch download and patch
# apply, respectively. We don't actually use the error codes, and instead
# rely on emitted json to determine cause of failure.
self(name, cmd, step_test_data=step_test_data,
step_result = self(name, cmd, step_test_data=step_test_data,
ok_ret=(0, 87, 88), **kwargs)
except self.m.step.StepFailure as f:
step_result = f.result
raise
finally:
step_result = self.m.step.active_result
if step_result:
self._last_returned_properties = step_result.json.output.get(
'properties', {})
if update_presentation:
# Set properties such as got_revision.
for prop_name, prop_value in self.last_returned_properties.iteritems():
for prop_name, prop_value in (
self.last_returned_properties.iteritems()):
step_result.presentation.properties[prop_name] = prop_value
# Add helpful step description in the step UI.
if 'step_text' in step_result.json.output:
......@@ -258,7 +263,8 @@ class BotUpdateApi(recipe_api.RecipeApi):
# Set the "checkout" path for the main solution.
# This is used by the Chromium module to figure out where to look for
# the checkout.
# If there is a patch failure, emit another step that said things failed.
# If there is a patch failure, emit another step that said things
# failed.
if step_result.json.output.get('patch_failure'):
return_code = step_result.json.output.get('patch_apply_return_code')
if return_code == 3:
......@@ -267,8 +273,8 @@ class BotUpdateApi(recipe_api.RecipeApi):
self.m.python.inline(
'Patch failure',
('import sys;'
'print "Patch download failed. See bot_update step for details";'
'sys.exit(1)'),
'print "Patch download failed. See bot_update step for'
' details";sys.exit(1)'),
infra_step=True,
step_test_data=lambda: self.m.raw_io.test_api.output(
'Patch download failed. See bot_update step for details',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment