summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2015-03-04 18:07:47 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-05 02:08:51 +0000
commit910d6e733bac30f15f76054eb101a81987f8c675 (patch)
tree07d492db264eb0938c91d39dabbf8f140a0e45be
parent4bb1b1ca394563b0f526d484b23b4e4d59de04af (diff)
downloadchromium_src-910d6e733bac30f15f76054eb101a81987f8c675.zip
chromium_src-910d6e733bac30f15f76054eb101a81987f8c675.tar.gz
chromium_src-910d6e733bac30f15f76054eb101a81987f8c675.tar.bz2
Telemetry: Add more details to inspector_backend exceptions.
Previously, inspector_backend would always throw a DevtoolsTargetCrashException. Now, it throws either a DevtoolsTargetCrashException or a TimeoutException. The CL also adds the debugger_url to the exception as further debugging information. There were exactly 2 files that tried to catch a DevtoolsTargetCrashException. I changed fast_navigation_profile_extender to catch Error instead. I will be improving this class in the future to have better exception handling. chrome_proxy_measurements caught a DevtoolsTargetCrashException, but its behavior is better suited by catching a TimeoutException. BUG=460625 Review URL: https://codereview.chromium.org/959423003 Cr-Commit-Position: refs/heads/master@{#319193}
-rw-r--r--tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py2
-rw-r--r--tools/perf/profile_creators/fast_navigation_profile_extender.py6
-rw-r--r--tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py49
3 files changed, 46 insertions, 11 deletions
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py b/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py
index 0261b14..7fe40df 100644
--- a/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py
@@ -93,7 +93,7 @@ class ChromeProxyValidation(page_test.PageTest):
if self._expect_timeout:
raise metrics.ChromeProxyMetricException, (
'Timeout was expected, but did not occur')
- except exceptions.DevtoolsTargetCrashException, e:
+ except exceptions.TimeoutException as e:
if self._expect_timeout:
logging.warning('Navigation timeout on page %s',
page.name if page.name else page.url)
diff --git a/tools/perf/profile_creators/fast_navigation_profile_extender.py b/tools/perf/profile_creators/fast_navigation_profile_extender.py
index e490403..abcc8eb 100644
--- a/tools/perf/profile_creators/fast_navigation_profile_extender.py
+++ b/tools/perf/profile_creators/fast_navigation_profile_extender.py
@@ -161,7 +161,7 @@ class FastNavigationProfileExtender(object):
"""Retrives the URL of the tab."""
try:
return tab.EvaluateJavaScript('document.URL', timeout)
- except (exceptions.DevtoolsTargetCrashException,
+ except (exceptions.Error,
devtools_http.DevToolsClientConnectionError,
devtools_http.DevToolsClientUrlError):
return None
@@ -204,7 +204,7 @@ class FastNavigationProfileExtender(object):
try:
tab.Navigate(url, None, timeout_in_seconds)
- except (exceptions.DevtoolsTargetCrashException,
+ except (exceptions.Error,
devtools_http.DevToolsClientConnectionError,
devtools_http.DevToolsClientUrlError):
# We expect a time out. It's possible for other problems to arise, but
@@ -242,7 +242,7 @@ class FastNavigationProfileExtender(object):
except exceptions.TimeoutException:
# Ignore time outs.
pass
- except (exceptions.DevtoolsTargetCrashException,
+ except (exceptions.Error,
devtools_http.DevToolsClientConnectionError,
devtools_http.DevToolsClientUrlError):
# If any error occurs, remove the tab. it's probably in an
diff --git a/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py b/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py
index 7361a38..886024e 100644
--- a/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome_inspector/inspector_backend.py
@@ -198,17 +198,52 @@ class InspectorBackend(object):
self._WaitForInspectorToGoAwayAndReconnect()
return
if res['method'] == 'Inspector.targetCrashed':
- raise exceptions.DevtoolsTargetCrashException(self.app)
+ exception = exceptions.DevtoolsTargetCrashException(self.app)
+ self._AddDebuggingInformation(exception)
+ raise exception
def _HandleError(self, error):
+ """Converts a websocket Exception into a Telemetry exception.
+
+ This method always raises a Telemetry exception. It appends debugging
+ information.
+
+ Args:
+ error: An instance of socket.error or websocket.WebSocketException.
+ Raises:
+ exception.TimeoutException: A timeout occured.
+ exception.DevtoolsTargetCrashException: On any other error, the most
+ likely explanation is that the devtool's target crashed.
+ """
+ if isinstance(error, websocket.WebSocketTimeoutException):
+ new_error = exceptions.TimeoutException()
+ else:
+ new_error = exceptions.DevtoolsTargetCrashException(self.app)
+
+ original_error_msg = 'Original exception:\n' + str(error)
+ new_error.AddDebuggingMessage(original_error_msg)
+ self._AddDebuggingInformation(new_error)
+
+ raise new_error
+
+ def _AddDebuggingInformation(self, error):
+ """Adds debugging information to error.
+
+ Args:
+ error: An instance of exceptions.Error.
+ """
if self.IsInspectable():
- raise exceptions.DevtoolsTargetCrashException(self.app,
+ msg = (
'Received a socket error in the browser connection and the tab '
- 'still exists, assuming it timed out. '
- 'Error=%s' % error)
- raise exceptions.DevtoolsTargetCrashException(self.app,
- 'Received a socket error in the browser connection and the tab no '
- 'longer exists, assuming it crashed. Error=%s' % error)
+ 'still exists. The operation probably timed out.'
+ )
+ else:
+ msg = (
+ 'Received a socket error in the browser connection and the tab no '
+ 'longer exists. The tab probably crashed.'
+ )
+ error.AddDebuggingMessage(msg)
+ error.AddDebuggingMessage('Debugger url: %s' % self.debugger_url)
def _WaitForInspectorToGoAwayAndReconnect(self):
sys.stderr.write('The connection to Chrome was lost to the Inspector UI.\n')