Skip to content

Commit

Permalink
BizHawkClient: Restore use of ConnectorErrors (ArchipelagoMW#2480)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zunawe authored and Jouramie committed Feb 28, 2024
1 parent 0dfa795 commit cc47262
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion worlds/_bizhawk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import base64
import enum
import json
import sys
import typing


Expand Down Expand Up @@ -125,7 +126,20 @@ async def send_requests(ctx: BizHawkContext, req_list: typing.List[typing.Dict[s
"""Sends a list of requests to the BizHawk connector and returns their responses.
It's likely you want to use the wrapper functions instead of this."""
return json.loads(await ctx._send_message(json.dumps(req_list)))
responses = json.loads(await ctx._send_message(json.dumps(req_list)))
errors: typing.List[ConnectorError] = []

for response in responses:
if response["type"] == "ERROR":
errors.append(ConnectorError(response["err"]))

if errors:
if sys.version_info >= (3, 11, 0):
raise ExceptionGroup("Connector script returned errors", errors) # noqa
else:
raise errors[0]

return responses


async def ping(ctx: BizHawkContext) -> None:
Expand Down

0 comments on commit cc47262

Please sign in to comment.