Skip to content

Commit

Permalink
Detect error in json using key in close_session() and close_tab()
Browse files Browse the repository at this point in the history
  • Loading branch information
neyberson committed Sep 6, 2024
1 parent 8eb068f commit 0032a62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions devtools/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ async def close_tab(self, target):
command="Target.closeTarget",
params={"targetId": target},
)
error = self.protocol.get_error(response)
if error:
raise RuntimeError("Could not close tab") from Exception(error)
if "error" in response:
raise RuntimeError("Could not close tab") from Exception(response["error"])
print(f"The tab {target} has been closed")
self.remove_tab(target)
return response
Expand Down
7 changes: 4 additions & 3 deletions devtools/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ async def close_session(self, session):
command="Target.detachFromTarget",
params={"sessionId": session},
)
error = self.protocol.get_error(response)
if error:
raise RuntimeError("Could not close session") from Exception(error)
if "error" in response:
raise RuntimeError("Could not close session") from Exception(
response["error"]
)
print(f"The session {session} has been closed")
self.remove_session(session)
return response
Expand Down

0 comments on commit 0032a62

Please sign in to comment.