Sha256: 9cca11175d7b97aa6698fabccb100460cc96369248ef1c85fb6846251a703cce

Contents?: true

Size: 626 Bytes

Versions: 16

Compression:

Stored size: 626 Bytes

Contents

require 'timeout'

module RescueExt
  def rescue_all default = nil, silent = false
    begin
      return yield
    rescue Exception => e
      unless silent
        Rails.logger.warn "Exception rescued:"
        Rails.logger.warn e
        if e.respond_to? :io
          Rails.logger.warn "URI: '#{e.io.meta['location']}'"
        end
        Rails.logger.warn e.backtrace.join("\n")
      end

      return default
    end
  end

  def silently_rescue_all default = nil, &block
    rescue_all default, true, &block
  end
  
  def timeout sec, default = nil
    rescue_all(default) {Timeout.timeout(sec) { yield }}
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
programmable-ventouse-0.0.1 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.10 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.2 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.3 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.4 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.5 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.7 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.8 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.0.9 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.1.0 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.1.1 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.1.2 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.1.3 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.1.4 lib/ventouse/rescue_ext.rb
programmable-ventouse-0.1.5 lib/ventouse/rescue_ext.rb
ventouse-0.1.6 lib/ventouse/rescue_ext.rb