diff --git a/aws_lambda_powertools/utilities/batch/exceptions.py b/aws_lambda_powertools/utilities/batch/exceptions.py index d90c25f12bc..65afd91801b 100644 --- a/aws_lambda_powertools/utilities/batch/exceptions.py +++ b/aws_lambda_powertools/utilities/batch/exceptions.py @@ -16,7 +16,7 @@ def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = Non def format_exceptions(self, parent_exception_str): exception_list = [f"{parent_exception_str}\n"] - for exception in self.child_exceptions: + for exception in self.child_exceptions or []: extype, ex, tb = exception formatted = "".join(traceback.format_exception(extype, ex, tb)) exception_list.append(formatted) diff --git a/tests/functional/test_utilities_batch.py b/tests/functional/test_utilities_batch.py index a5e1e706437..757d2ddc398 100644 --- a/tests/functional/test_utilities_batch.py +++ b/tests/functional/test_utilities_batch.py @@ -908,3 +908,7 @@ def lambda_handler(event, context): # THEN raise BatchProcessingError assert "All records failed processing. " in str(e.value) + + +def test_child_exceptions_is_none(): + assert str(SQSBatchProcessingError()) == "\n"