Skip to content

Commit d00425f

Browse files
authored
chore(batch): safeguard custom use of BatchProcessingError exception (aws-powertools#2155)
1 parent 73acf3c commit d00425f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

aws_lambda_powertools/utilities/batch/exceptions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
Batch processing exceptions
33
"""
4+
from __future__ import annotations
5+
46
import traceback
57
from types import TracebackType
68
from typing import List, Optional, Tuple, Type
@@ -9,10 +11,10 @@
911

1012

1113
class BaseBatchProcessingError(Exception):
12-
def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = None):
14+
def __init__(self, msg="", child_exceptions: List[ExceptionInfo] | None = None):
1315
super().__init__(msg)
1416
self.msg = msg
15-
self.child_exceptions = child_exceptions
17+
self.child_exceptions = child_exceptions or []
1618

1719
def format_exceptions(self, parent_exception_str):
1820
exception_list = [f"{parent_exception_str}\n"]
@@ -27,7 +29,7 @@ def format_exceptions(self, parent_exception_str):
2729
class BatchProcessingError(BaseBatchProcessingError):
2830
"""When all batch records failed to be processed"""
2931

30-
def __init__(self, msg="", child_exceptions: Optional[List[ExceptionInfo]] = None):
32+
def __init__(self, msg="", child_exceptions: List[ExceptionInfo] | None = None):
3133
super().__init__(msg, child_exceptions)
3234

3335
def __str__(self):

0 commit comments

Comments
 (0)