Fix aggregate execution error message

This commit is contained in:
Andrew Kay
2025-09-04 08:20:25 -05:00
parent 13181865ed
commit 7f5b474c8a
2 changed files with 31 additions and 5 deletions

View File

@@ -13,10 +13,15 @@ logger = logging.getLogger(__name__)
class ExecuteError(Exception):
def __init__(self, errors, responses):
if len(errors) == 1:
message = str(errors[0])
else:
message = f'{len(errors)} occurred'
if not errors:
raise ValueError('Errors required')
message = str(errors[0]) or repr(errors[0])
if len(errors) == 2:
message += ' and 1 other error'
elif len(errors) > 2:
message += f' and {len(errors) - 1} other errors'
super().__init__(message)