Sha256: ff540f5ec5ffa64e37337d8b300485b0669ee7e897a59237fcc25292efc54ed1

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

require 'net/http'
require 'net/https'
require 'rubygems'

begin
  require 'active_support'
  require 'active_support/core_ext'
rescue LoadError
  require 'activesupport'
  require 'activesupport/core_ext'
end

require "errplane/version"
require "errplane/black_box"
require "errplane/configuration"
require "errplane/transmitter"
require "errplane/rack"

require "errplane/railtie" #if defined?(Rails)

module Errplane
  API_HOST = "api.errplane.com"

  class << self
    attr_writer :configuration
    attr_accessor :transmitter

    def configure(silent = false)
      yield(configuration)
      self.transmitter = Transmitter.new(configuration)
    end

    def configuration
      @configuration ||= Configuration.new
    end

    def transmit_to_api(exception)
      transmitter.relay(assemble_black_box_for(exception)) unless ignorable_exception?(exception)
    end

    def ignorable_exception?(exception)
      return configuration.ignored_exceptions.include?(exception.class.to_s)
    end

    private
    def assemble_black_box_for(exception, options = {})
      exception = unwrap_exception(exception)
      black_box = BlackBox.new(exception: exception)
    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

1 entries across 1 versions & 1 rubygems

Version Path
errplane-0.0.2 lib/errplane.rb