Sha256: b65612d36d0e0ef2480db0a356861cccb5581d04024e6ab537cabe17f6f44698
Contents?: true
Size: 935 Bytes
Versions: 17
Compression:
Stored size: 935 Bytes
Contents
module Footnotes module EachWithRescue def self.included(base) base.send :include, InstanceMethods end module InstanceMethods # Process notes, discarding only the note if any problem occurs # def each_with_rescue(collection) delete_me = [] collection.each do |item| begin yield item rescue Exception => e raise e if Rails.env.test? # Discard item if it has a problem log_error("Footnotes #{item.to_s.camelize} Exception", e) delete_me << item next end end delete_me.each { |item| collection.delete(item) } return collection end # Logs the error using specified title and format # def log_error(title, exception) Rails.logger.error "#{title}: #{exception}\n#{exception.backtrace.join("\n")}" end end end end
Version data entries
17 entries across 17 versions & 2 rubygems