Bug 1461463 - [wdclient] "message" argument of WebDriverException has to be optional. draft
authorHenrik Skupin <mail@hskupin.info>
Thu, 24 May 2018 17:33:45 +0200
changeset 800976 0518792ebf5b08c512a2a63c8b71ea5387407271
parent 800975 a72d1d92e396b65af97fd29f2d4aa076751a42d5
child 800977 731ae50a8e878ab8cbc9df3bbd6c853e5fb3ee73
push id111539
push userbmo:hskupin@gmail.com
push dateTue, 29 May 2018 15:41:27 +0000
bugs1461463
milestone62.0a1
Bug 1461463 - [wdclient] "message" argument of WebDriverException has to be optional. MozReview-Commit-ID: 3atuW15tUOa
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,31 +1,34 @@
 import collections
 import json
 
 
 class WebDriverException(Exception):
     http_status = None
     status_code = None
 
-    def __init__(self, message, stacktrace=None):
+    def __init__(self, message=None, stacktrace=None):
         super(WebDriverException, self)
         self.message = message
         self.stacktrace = stacktrace
 
     def __repr__(self):
         return "<%s http_status=%s>" % (self.__class__.__name__, self.http_status)
 
     def __str__(self):
-        message = "%s (%s): %s\n" % (self.status_code, self.http_status, self.message)
+        message = "%s (%s)" % (self.status_code, self.http_status)
+
+        if self.message is not None:
+            message += ": %s" % self.message
+        message += "\n"
+
         if self.stacktrace:
-            message += ("\n"
-            "Remote-end stacktrace:\n"
-            "\n"
-            "%s" % self.stacktrace)
+            message += ("\nRemote-end stacktrace:\n\n%s" % self.stacktrace)
+
         return message
 
 
 class ElementClickInterceptedException(WebDriverException):
     http_status = 400
     status_code = "element click intercepted"