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

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: make isolate_smoke_test less strict regarding exact contents of stderr 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
« no previous file with comments | « 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..2885954faca8a2040e4ec9f04fc5779f45ba774d 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,23 @@ def fix_python_path(cmd):
elif out[0].endswith('.py'):
out.insert(0, sys.executable)
return out
+
+
+def report_error(error):
+ """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:
+ error: error message string (possibly multiple lines) or an instance of
+ Exception subclass. In the later case a traceback will also be
+ reported. It's assumed that |report_error| is called in an except
+ block where |error| was caught.
+ """
+ print >> sys.stderr, '[------ Swarming Error ------]'
+ print >> sys.stderr, str(error)
+ if isinstance(error, Exception):
+ print >> sys.stderr, traceback.format_exc(),
+ print >> sys.stderr, '[----------------------------]'
« no previous file with comments | « tests/run_isolated_smoke_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698