Skip to content

Commit

Permalink
Merge branch 'trunk' into js-bidi-network-events
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 authored Jun 14, 2023
2 parents 765747d + d1f1b6f commit 2b0ad32
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions py/selenium/webdriver/common/bidi/cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class BrowserError(Exception):
indicates that an error occurred."""

def __init__(self, obj):
self.code = obj["code"]
self.message = obj["message"]
self.code = obj.get("code")
self.message = obj.get("message")
self.detail = obj.get("data")

def __str__(self):
Expand Down Expand Up @@ -442,7 +442,13 @@ async def _reader_task(self):
try:
session = self.sessions[session_id]
except KeyError:
raise BrowserError(f"Browser sent a message for an invalid session: {session_id!r}")
raise BrowserError(
{
"code": -32700,
"message": "Browser sent a message for an invalid session",
"data": f"{session_id!r}",
}
)
session._handle_data(data)
else:
self._handle_data(data)
Expand Down

0 comments on commit 2b0ad32

Please sign in to comment.