Bug 1150527 - Remove error numbers from Marionette Python client; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Wed, 16 Nov 2016 16:21:06 +0000
changeset 439794 f72b3cbd01f207dcdf81884cbcc88bf44b6e2e15
parent 439734 51750761f2c61c64cf0553f6cb5fefd4999d3bc0
child 439795 24725ef71f76c22713e3b8b501d87a0d7e535e2c
push id36095
push userbmo:ato@mozilla.com
push dateWed, 16 Nov 2016 16:28:16 +0000
reviewersautomatedtester
bugs1150527
milestone53.0a1
Bug 1150527 - Remove error numbers from Marionette Python client; r?automatedtester MozReview-Commit-ID: IGAdxItviaz
testing/marionette/client/marionette_driver/errors.py
--- a/testing/marionette/client/marionette_driver/errors.py
+++ b/testing/marionette/client/marionette_driver/errors.py
@@ -8,17 +8,16 @@ import traceback
 class InstallGeckoError(Exception):
     pass
 
 
 class MarionetteException(Exception):
 
     """Raised when a generic non-recoverable exception has occured."""
 
-    code = (500,)
     status = "webdriver error"
 
     def __init__(self, message=None, cause=None, stacktrace=None):
         """Construct new MarionetteException instance.
 
         :param message: An optional exception message.
 
         :param cause: An optional tuple of three values giving
@@ -64,130 +63,108 @@ class InvalidArgumentException(Marionett
     status = "invalid argument"
 
 
 class InvalidSessionIdException(MarionetteException):
     status = "invalid session id"
 
 
 class TimeoutException(MarionetteException):
-    code = (21,)
     status = "timeout"
 
 
 class JavascriptException(MarionetteException):
-    code = (17,)
     status = "javascript error"
 
 
 class NoSuchElementException(MarionetteException):
-    code = (7,)
     status = "no such element"
 
 
 class NoSuchWindowException(MarionetteException):
-    code = (23,)
     status = "no such window"
 
 
 class StaleElementException(MarionetteException):
-    code = (10,)
     status = "stale element reference"
 
 
 class ScriptTimeoutException(MarionetteException):
-    code = (28,)
     status = "script timeout"
 
 
 class ElementNotVisibleException(MarionetteException):
-    code = (11,)
     status = "element not visible"
 
     def __init__(self,
                  message="Element is not currently visible and may not be manipulated",
                  stacktrace=None, cause=None):
         super(ElementNotVisibleException, self).__init__(
             message, cause=cause, stacktrace=stacktrace)
 
 
 class ElementNotAccessibleException(MarionetteException):
-    code = (56,)
     status = "element not accessible"
 
 
 class NoSuchFrameException(MarionetteException):
-    code = (8,)
     status = "no such frame"
 
 
 class InvalidElementStateException(MarionetteException):
-    code = (12,)
     status = "invalid element state"
 
 
 class NoAlertPresentException(MarionetteException):
-    code = (27,)
     status = "no such alert"
 
 
 class InvalidCookieDomainException(MarionetteException):
-    code = (24,)
     status = "invalid cookie domain"
 
 
 class UnableToSetCookieException(MarionetteException):
-    code = (25,)
     status = "unable to set cookie"
 
 
 class InvalidElementCoordinates(MarionetteException):
-    code = (29,)
     status = "invalid element coordinates"
 
 
 class InvalidSelectorException(MarionetteException):
-    code = (32, 51, 52)
     status = "invalid selector"
 
 
 class MoveTargetOutOfBoundsException(MarionetteException):
-    code = (34,)
     status = "move target out of bounds"
 
 
 class SessionNotCreatedException(MarionetteException):
-    code = (33, 71)
     status = "session not created"
 
 
 class UnexpectedAlertOpen(MarionetteException):
-    code = (26,)
     status = "unexpected alert open"
 
 
 class UnknownCommandException(MarionetteException):
-    code = (9,)
     status = "unknown command"
 
 
 class UnknownException(MarionetteException):
-    code = (13,)
     status = "unknown error"
 
 
 class UnsupportedOperationException(MarionetteException):
-    code = (405,)
     status = "unsupported operation"
 
 
-es_ = [e for e in locals().values() if type(e) == type and issubclass(e, MarionetteException)]
+es_ = [e for e in locals().values() if type(
+    e) == type and issubclass(e, MarionetteException)]
 by_string = {e.status: e for e in es_}
-by_number = {c: e for e in es_ for c in e.code}
 
 
 def lookup(identifier):
     """Finds error exception class by associated Selenium JSON wire
-    protocol number code, or W3C WebDriver protocol string."""
-    lookup = by_string
-    if isinstance(identifier, int):
-        lookup = by_number
-    return lookup.get(identifier, MarionetteException)
+    protocol number code, or W3C WebDriver protocol string.
+
+    """
+    return by_string.get(identifier, MarionetteException)