Sha256: c0be0be0523e3d72f91b81d28e1c1d97d60cda237b04536d5d48fd9a9c534a68

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'yogi_berra/catcher'
require 'yogi_berra/backtrace'
require 'yogi_berra/notice'
require 'yogi_berra/exception_middleware'
require 'yogi_berra/data'
require 'yogi_berra/logger'

if defined?(::Rails.version) && ::Rails.version.to_f >= 3.0
  require 'yogi_berra/engine'
else
  require 'yogi_berra/rails'
end

module YogiBerra
  class << self
    # Stores the notice exception
    # @see YogiBerra.exceptionize
    # @params exception
    # @params environment
    # @params database
    def exceptionize(exception, environment, database, opts = {})
      notice = build_notice_for(exception, opts)
      if database
        YogiBerra::Data.store!(notice, environment, database)
      else
        YogiBerra::Logger.log("No database connection!", :error)
      end
    end

    private

    def build_notice_for(exception, opts = {})
      exception = unwrap_exception(exception)
      if exception.respond_to?(:to_hash)
        opts = opts.merge(exception.to_hash)
      else
        opts = opts.merge(:exception => exception)
      end
      Notice.new(opts)
    end

    def unwrap_exception(exception)
      if exception.respond_to?(:original_exception)
        exception.original_exception
      elsif exception.respond_to?(:continued_exception)
        exception.continued_exception
      else
        exception
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yogi_berra-0.0.3 lib/yogi_berra.rb
yogi_berra-0.0.2 lib/yogi_berra.rb