| 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, '[----------------------------]'
|
|
|