File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -483,7 +483,7 @@ private void captureMessage(final RaiseException re) {
483483 rubyException .callMethod (context , "capture" );
484484 rubyException .callMethod (context , "store" );
485485 }
486- catch (Exception e ) {
486+ catch (Throwable e ) {
487487 rackContext .log (INFO , "failed to capture exception message" , e );
488488 // won't be able to capture anything
489489 }
Original file line number Diff line number Diff line change @@ -487,6 +487,35 @@ def reset_config
487487 expect ( e . message ) . to eql 'something went wrong'
488488 end
489489 end
490+
491+ it "swallows and logs errors during exception detail capturing" do
492+ expect ( @rack_config ) . to receive ( :getRackup ) . and_return ( "raise 'something went wrong'" )
493+ expect_any_instance_of ( Exception ) . to receive ( :capture ) . and_raise java . lang . NoClassDefFoundError . new ( "missing class during exception capture" )
494+
495+ app_factory = mocked_runtime_application_factory
496+ app_factory . init @rack_context
497+ app_object = app_factory . newApplication
498+
499+ raise_info_logged = 0
500+ allow ( @rack_context ) . to receive ( :log ) do |level , msg , e |
501+ if level . to_s == 'INFO'
502+ expect ( msg ) . to eql 'failed to capture exception message'
503+ expect ( e ) . to be_a java . lang . NoClassDefFoundError
504+ raise_info_logged += 1
505+ else
506+ true
507+ end
508+ end
509+
510+ begin
511+ app_object . init
512+ fail "expected to raise"
513+ rescue => e
514+ expect ( e . message ) . to eql 'something went wrong' # original error
515+ end
516+
517+ expect ( raise_info_logged ) . to eql 1 # logs info message for exception capture
518+ end
490519 end
491520
492521 describe "getApplication" do
You can’t perform that action at this time.
0 commit comments