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

Unified Diff: utils/tools.py

Issue 51383003: Report all swarming and isolate fatal errors in a consistent way. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Created 7 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
« isolate.py ('K') | « tests/run_isolated_smoke_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/tools.py
diff --git a/utils/tools.py b/utils/tools.py
index eecf709641bc8497a3d8e57480a65b3a8071d029..1c793a68f92928ae642e27673c8268cf587ab376 100644
--- a/utils/tools.py
+++ b/utils/tools.py
@@ -10,6 +10,7 @@ import optparse
import os
import sys
import time
+import traceback
class OptionParserWithLogging(optparse.OptionParser):
@@ -112,3 +113,21 @@ def fix_python_path(cmd):
elif out[0].endswith('.py'):
out.insert(0, sys.executable)
return out
+
+
+def report_error(message, include_traceback=False):
+ """Prints a error to stderr, wrapping it into header and footer.
+
+ That way errors can be reliably extracted from logs. It's indented to be used
+ only for non recoverable unexpected errors. Is should NOT be used for input
+ validation, command line argument errors, etc.
+
+ Arguments:
+ message: error message string, possibly multiple lines.
+ include_traceback: True to append traceback of current exception.
+ """
+ print >> sys.stderr, '[------ Swarming Error ------]'
+ print >> sys.stderr, message
+ if include_traceback:
+ print >> sys.stderr, traceback.format_exc(),
+ print >> sys.stderr, '[----------------------------]'
« isolate.py ('K') | « tests/run_isolated_smoke_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698