Rescue from ‘execution expired’ in Ruby

Today I was trying to rescue from an ‘execution expired’ error when using another colleagues gem (which interfaces with an XML RPC API).

Thankfully I found this snippet at http://geoff.evason.name/2011/01/16/rescue-from-execution-expired-in-ruby/.

      begin
        # do something involving Net:HTTP
      rescue => e
        # This will NOT catch 'execution expired' !!
        puts "Rescue : #{e}"
      rescue Timeout::Error => te
        # This explicit rescue will work
        puts "Rescued from timeout : #{te}"
      end

Hopefully this will save someone a bit of time :).

Leave a Reply