Sha256: 2811902bab2f81a27a7215b016b43aa15ad6dbac7e85632c19fa4069d759ec59

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

module Houston

  def self.report_exception(exception, other_data={})
    if Rails.env.test? || Rails.env.development?
      Rails.logger.error "\e[31;1m#{exception.class}: #{exception.message}\n#{exception.backtrace.join("\n  ")}\e[0m"
      return
    end

    begin
      Rails.logger.error "#{exception.class}: #{exception.message}\n#{exception.backtrace.join("\n  ")}"

      if defined?(Airbrake)
        other_data[:parameters] ||= {}
        case exception
        when Faraday::HTTP::Error
          other_data[:parameters].merge!(_normalize_faraday_env(exception.env))
        end
        other_data[:parameters].merge!(exception.additional_information)
        Airbrake.notify(exception, other_data)
      end
    rescue Exception => e
      Rails.logger.error "\e[31;1mAn error occurred reporting the exception: \e[0;31m#{e.class}: #{e.message}\n   #{e.backtrace.join("\n  ")}\e[0m"
    end
  end

  def self._normalize_faraday_env(env)
    env.except(:response).tap do |env|
      env[:url] = env[:url].to_s
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre config/initializers/houston_report_exception.rb
houston-core-0.7.0 config/initializers/houston_report_exception.rb
houston-core-0.7.0.beta4 config/initializers/houston_report_exception.rb
houston-core-0.7.0.beta3 config/initializers/houston_report_exception.rb
houston-core-0.7.0.beta2 config/initializers/houston_report_exception.rb
houston-core-0.7.0.beta config/initializers/houston_report_exception.rb