File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,13 @@ def handle_error(self, e):
592
592
'''
593
593
got_request_exception .send (current_app ._get_current_object (), exception = e )
594
594
595
+ if not isinstance (e , HTTPException ) and current_app .propagate_exceptions :
596
+ exc_type , exc_value , tb = sys .exc_info ()
597
+ if exc_value is e :
598
+ raise
599
+ else :
600
+ raise e
601
+
595
602
include_message_in_response = current_app .config .get ("ERROR_INCLUDE_MESSAGE" , True )
596
603
default_data = {}
597
604
Original file line number Diff line number Diff line change @@ -291,12 +291,12 @@ def get(self):
291
291
292
292
app .config ['PROPAGATE_EXCEPTIONS' ] = True
293
293
294
- response = client . get ( '/api/test/' )
295
- assert response . status_code == 500
296
- assert response . content_type == 'application/json'
297
-
298
- data = json . loads ( response . data . decode ( 'utf8' ))
299
- assert 'message' in data
294
+ # From the Flask docs:
295
+ # PROPAGATE_EXCEPTIONS
296
+ # Exceptions are re-raised rather than being handled by the app’s error handlers.
297
+ # If not set, this is implicitly true if TESTING or DEBUG is enabled.
298
+ with pytest . raises ( Exception ):
299
+ client . get ( '/api/test/' )
300
300
301
301
def test_custom_default_errorhandler (self , app , client ):
302
302
api = restplus .Api (app )
You can’t perform that action at this time.
0 commit comments