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

Unified Diff: recipe_engine/run.py

Issue 2798053003: introduce recipe_exception in result.proto (Closed)
Patch Set: Created 3 years, 8 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 | « recipe_engine/result_pb2.py ('k') | recipe_engine/step_runner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/run.py
diff --git a/recipe_engine/run.py b/recipe_engine/run.py
index 77c9b4e5f187a4f3c0961db17c651402ee110e31..b6fee45accb9ce8cf64a26f6de4a67e7030303e7 100644
--- a/recipe_engine/run.py
+++ b/recipe_engine/run.py
@@ -335,6 +335,17 @@ class RecipeEngine(object):
result.failure.human_reason = "Step time out: %r" % ex
result.failure.timeout.timeout_s = ex.timeout
+ except loader.RecipeException as ex:
+ result.failure.human_reason = "Uncaught Exception: %r" % ex
+ result.failure.recipe_exception.traceback[:] = [
+ line.rstrip('\n')
+ for line in traceback.format_exception(
+ type(ex.inner_exception), ex.inner_exception, ex.traceback)
+ ]
+
+ # Let the step runner run_context decide what to do.
+ raise type(ex.inner_exception), ex.inner_exception, ex.traceback
+
except Exception as ex:
result.failure.human_reason = "Uncaught Exception: %r" % ex
result.failure.exception.traceback[:] = (
@@ -377,13 +388,24 @@ class RecipeEngine(object):
"traceback": traceback.format_exc().splitlines(),
"status_code": -1
}
+ except loader.RecipeException as ex:
+ result = {
+ "reason": "Uncaught Exception: %r" % ex.inner_exception,
+ "traceback": [
+ line.rstrip('\n')
+ for line in traceback.format_exception(
+ type(ex.inner_exception), ex.inner_exception, ex.traceback)
+ ],
+ "status_code": -1
+ }
+ assert all('\n' not in line for line in result["traceback"])
+ raise type(ex.inner_exception), ex.inner_exception, ex.traceback
except Exception as ex:
result = {
"reason": "Uncaught Exception: %r" % ex,
"traceback": traceback.format_exc().splitlines(),
"status_code": -1
}
-
raise
result['name'] = '$result'
« no previous file with comments | « recipe_engine/result_pb2.py ('k') | recipe_engine/step_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698