# Custom fail message on an around hook with a Timeout exception

**URL:** <https://www.ruby-forum.com/t/custom-fail-message-on-an-around-hook-with-a-timeout-exception/267563>\
**Category:** RSpec\
**Created:** [March 13, 2025, 3:35am UTC](https://www.ruby-forum.com/t/custom-fail-message-on-an-around-hook-with-a-timeout-exception/267563 "2025-03-13T03:35:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gditrick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ed655f/32.png) [@gditrick](https://www.ruby-forum.com/u/gditrick)\
**Post date:** [March 13, 2025, 3:35am UTC](https://www.ruby-forum.com/t/custom-fail-message-on-an-around-hook-with-a-timeout-exception/267563/1 "2025-03-13T03:35:48Z")

</div>

doing this which works to make sure that no infinite loop happens:

RSpec.configure do |config|  
config.around(:example, finite: true) do |example|  
Timeout.timeout(wait\_time) do  
example.run  
end  
end  
end

My desired example is:

it “should not run over #{wait\_time} seconds”, finite: true do  
run and tests  
end

But, on a Time failure I want to add the details of the Timeout failure to reproduce it in a console and I don’t want those details on a success. On a success, I just want the the original example description.

Right now, I can only dynamically put the details on the example description similar to this:

it “should not run over #{wait\_time} seconds\n#{dump\_teams(team\_ids, statement)}”, finite: true do  
…blah, blah, blah…  
end

The dump\_teams can produce a very very large string and makes the summary report very very large.

Is there a way to append to the description in that around hook? I tried a rescue. I tried other things. Any ideas?
