Skip to content

Commit

Permalink
Store the WebDriver error "data" property
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnedders committed Jan 14, 2025
1 parent e9b613b commit 06be9fb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tools/webdriver/webdriver/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ class WebDriverException(Exception):
http_status: ClassVar[int]
status_code: ClassVar[str]

def __init__(self, http_status=None, status_code=None, message=None, stacktrace=None):
def __init__(
self,
http_status=None,
status_code=None,
message=None,
stacktrace=None,
data=None,
):
super().__init__()

if http_status is not None:
Expand All @@ -25,6 +32,7 @@ def __init__(self, http_status=None, status_code=None, message=None, stacktrace=
self.status_code = status_code
self.message = message
self.stacktrace = stacktrace
self.data = data

def __repr__(self):
return f"<{self.__class__.__name__} http_status={self.http_status}>"
Expand Down Expand Up @@ -214,9 +222,11 @@ def from_response(response):
code = value["error"]
message = value["message"] or None
stack = value["stacktrace"] or None
# data is optional, and could even be an empty dict
data = value.get("data") or None

cls = get(code)
return cls(response.status, code, message, stacktrace=stack)
return cls(response.status, code, message, stacktrace=stack, data=data)


def get(error_code):
Expand Down

0 comments on commit 06be9fb

Please sign in to comment.