Sha256: caad2e33ca7b9dd93366b8f13e3f359d24fbaa4727c147c3a493acb20dec2efc

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

# encoding: utf-8
require 'toadhopper'

module Adhearsion
  class Reporter < Plugin
    config :reporter do
      api_key nil,                  :desc => "The Airbrake/Errbit API key"
      url     "http://airbrake.io", :desc => "Base URL for notification service"
    end

    init :reporter do
      config = Adhearsion.config[:reporter]
      notifier = Toadhopper.new config.api_key, :notify_host => config.url
      Events.register_callback(:exception) do |e|
        response = notifier.post!(e)
        if !response.errors.empty? || !(200..299).include?(response.status.to_i)
          logger.error "Error posting exception to #{config.url}! Response code #{response.status}"
          response.errors.each do |error|
            logger.error "#{error}"
          end
          logger.warn "Original exception message: #{e.message}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adhearsion-reporter-2.0.0 lib/adhearsion/reporter.rb