From 9a96480e61637bcdce3a78222db548d0fe122ec5 Mon Sep 17 00:00:00 2001 From: Zunawe Date: Thu, 23 Nov 2023 08:54:31 -0800 Subject: [PATCH] BizHawkClient: Use ExceptionGroup for connector errors if available --- worlds/_bizhawk/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/worlds/_bizhawk/__init__.py b/worlds/_bizhawk/__init__.py index 0b3b1837b6d3..5597aa9fb118 100644 --- a/worlds/_bizhawk/__init__.py +++ b/worlds/_bizhawk/__init__.py @@ -9,6 +9,7 @@ import base64 import enum import json +import sys import typing @@ -114,10 +115,18 @@ async def send_requests(ctx: BizHawkContext, req_list: typing.List[typing.Dict[s It's likely you want to use the wrapper functions instead of this.""" responses = json.loads(await ctx._send_message(json.dumps(req_list))) + errors: typing.List[ConnectorError] = [] + for response in responses: if response["type"] == "ERROR": - raise ConnectorError(response["err"]) - + errors.append(ConnectorError(response["err"])) + + if errors: + if sys.version_info >= (3, 11, 0): + raise ExceptionGroup("Connector script returned errors", errors) + else: + raise errors[0] + return responses