Sha256: 252afef539c75019c7dd8d1bf6afba7c5b17eecfbc9b096fe3ae3374f8eafcc0

Contents?: true

Size: 1.25 KB

Versions: 11

Compression:

Stored size: 1.25 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 opts
    def exceptionize(exception, environment = nil, opts = {})
      notice = build_notice_for(exception, opts)
      if YogiBerra::Catcher.connection
        YogiBerra::Data.store!(notice, environment)
      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

11 entries across 11 versions & 1 rubygems

Version Path
yogi_berra-0.1.7 lib/yogi_berra.rb
yogi_berra-0.1.6 lib/yogi_berra.rb
yogi_berra-0.1.4 lib/yogi_berra.rb
yogi_berra-0.1.3 lib/yogi_berra.rb
yogi_berra-0.1.1 lib/yogi_berra.rb
yogi_berra-0.1.0 lib/yogi_berra.rb
yogi_berra-0.0.15 lib/yogi_berra.rb
yogi_berra-0.0.14 lib/yogi_berra.rb
yogi_berra-0.0.13 lib/yogi_berra.rb
yogi_berra-0.0.12 lib/yogi_berra.rb
yogi_berra-0.0.11 lib/yogi_berra.rb