Bug 1411045 - Add object- and string representations for WebDriverException. r?maja_zf draft
authorAndreas Tolfsen <ato@sny.no>
Mon, 23 Oct 2017 22:07:38 +0100
changeset 685976 5da2f73225fa5142dc339d099ce1fa62a5a5a0e2
parent 685608 a124f4901430f6db74cfc7fe3b07957a1c691b40
child 685977 c253ab4b82848dd37b95eca96775d029b95da033
push id86054
push userbmo:ato@sny.no
push dateWed, 25 Oct 2017 07:41:54 +0000
reviewersmaja_zf
bugs1411045
milestone58.0a1
Bug 1411045 - Add object- and string representations for WebDriverException. r?maja_zf MozReview-Commit-ID: C6gdV9B8aIU
testing/web-platform/tests/tools/webdriver/webdriver/error.py
--- a/testing/web-platform/tests/tools/webdriver/webdriver/error.py
+++ b/testing/web-platform/tests/tools/webdriver/webdriver/error.py
@@ -1,15 +1,29 @@
 import collections
 
 
 class WebDriverException(Exception):
     http_status = None
     status_code = None
 
+    def __init__(self, message, stacktrace=None):
+        super(WebDriverException, self)
+        self.stacktrace = stacktrace
+
+    def __repr__(self):
+        return "<%s http_status=%d>" % (self.__class__.__name__, self.http_status)
+
+    def __str__(self):
+        return ("%s (%d)\n"
+            "\n"
+            "Remote-end stacktrace:\n"
+            "\n"
+            "%s" % (self.status_code, self.http_status, self.stacktrace))
+
 
 class ElementNotSelectableException(WebDriverException):
     http_status = 400
     status_code = "element not selectable"
 
 
 class ElementNotVisibleException(WebDriverException):
     http_status = 400