File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -136,8 +136,8 @@ def decorator(func):
136136 def wrapper (* args , ** kwargs ):
137137 try :
138138 return func (* args , ** kwargs )
139- except tuple ([ handler .exception for handler in handlers ] ) as ex : # noqa: pylint - catching-non-exception
140- failed_handler = [handler for handler in handlers if handler .exception is type ( ex )][0 ]
139+ except tuple (handler .exception for handler in handlers ) as ex : # noqa: pylint - catching-non-exception
140+ failed_handler = [handler for handler in handlers if isinstance ( ex , handler .exception )][0 ]
141141 message = failed_handler .friendly_message
142142
143143 if message and str (ex ):
Original file line number Diff line number Diff line change 33LONG_DESCRIPTION = open ("README.md" ).read ()
44
55setup (name = "aws-lambda-decorators" ,
6- version = "0.46 " ,
6+ version = "0.47 " ,
77 description = "A set of python decorators to simplify aws python lambda development" ,
88 long_description = LONG_DESCRIPTION ,
99 long_description_content_type = "text/markdown" ,
Original file line number Diff line number Diff line change @@ -459,6 +459,20 @@ def handler():
459459
460460 mock_logger .error .assert_called_once_with ("%s: %s" , "error" , "'blank'" )
461461
462+ @patch ("aws_lambda_decorators.decorators.LOGGER" )
463+ def test_exception_handler_raises_exception_with_inherited_exception (self , mock_logger ):
464+
465+ @handle_exceptions (handlers = [ExceptionHandler (Exception )])
466+ def handler ():
467+ raise KeyError ("blank" )
468+
469+ response = handler ()
470+
471+ self .assertEqual (400 , response ["statusCode" ])
472+ self .assertTrue ("blank" in response ["body" ])
473+
474+ mock_logger .error .assert_called_once_with ("'blank'" )
475+
462476 @patch ("aws_lambda_decorators.decorators.LOGGER" )
463477 def test_log_decorator_can_log_params (self , mock_logger ): # noqa: pylint - no-self-use
464478
You can’t perform that action at this time.
0 commit comments