Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A base library for Hoptoad error reporting
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
resources
test
.gitignore
.travis.yml
.yardopts
CHANGELOG.md
Gemfile
LICENSE
README.md
Rakefile
toadhopper.gemspec

README.md

Build Status

A base library for Airbrake error reporting.

Toadhopper can be used to report plain old Ruby exceptions, or to build a framework-specific gem such as toadhopper-sinatra.

begin
  raise "Kaboom!"
rescue  => e
  require 'toadhopper'
  Toadhopper("YOURAPIKEY").post!(e)
end

You can install it via rubygems:

gem install toadhopper

Posting Notices Over SSL

Toadhopper can transport your messages over SSL.

To enable SSL, just specify a :notify_host with a https:// protocol.

Toadhopper.new("YOURAPIKEY", :notify_host => 'https://airbrake.io').post!(e)

Note: You must have a paid plan for Airbrake to accept your messages over SSL.

Example with :transport

Control freaks can customize a Net::HTTP to their liking with :transport.

require 'net/https'
require 'toadhopper'

def my_transport
  domain  = 'api.airbrake.io'
  port    = 443
  transport = Net::HTTP.new domain, port
  transport.set_debug_output $stderr # View verbose debugging
  transport.use_ssl       = true
  transport.ca_file       = Toadhopper::CA_FILE
  transport.verify_mode   = OpenSSL::SSL::VERIFY_PEER
  transport.open_timeout  = 7 # seconds
  transport.read_timeout  = 5 # seconds
  transport
end

def my_exception_handler(exception)
  api_key = 'YOURAPIKEY'
  Toadhopper.new(api_key, :transport => my_transport).post! exception
end

Deploy tracking

You can use Toadhopper to notify Airbrake of deployments:

Toadhopper('YOURAPIKEY').deploy!

The method accepts options to set the environment, SCM revision, etc.

There is Capistrano support for deploy tracking. Simply require toadhopper/capistrano in your deploy config and set the variable airbrake_api_key:

require 'toadhopper/capistrano'

set :airbrake_api_key, 'YOURAPIKEY'

Supported Capistrano Keys

  • :airbrake_notify_host
  • :airbrake_error_url
  • :airbrake_deploy_url
  • :airbrake_transport

Compatibility

Toadhopper is tested against and compatible with the following ruby platforms:

  • 1.8.7
  • 1.9.2
  • 1.9.3
  • ree 1.8.7-2012.02
  • jruby 1.6.7 in both 1.8 mode and 1.9 mode
  • rubinius 2.0.testing branch in both 1.8 mode and 1.9 mode

    For jruby support, you need to gem install jruby-openssl if you do not already have that gem. More info on why this is.

Development

Install Bundler 0.9.x, then:

% git clone git://github.com/toolmantim/toadhopper.git
% cd toadhopper
% bundle install
% bundle exec rake test

If you set a AIRBRAKE_API_KEY environment variable it'll test actually posting to the Airbrake API. For example:

% bundle exec rake test AIRBRAKE_API_KEY=abc123

Set AIRBRAKE_FULL_TEST to test integration operations that require a paid Airbrake plan such as posting over SSL, deploy tracking, and github integration. For example:

% bundle exec rake test AIRBRAKE_API_KEY=abc123 AIRBRAKE_FULL_TEST=1

Beware: Setting AIRBRAKE_FULL_TEST will record a bogus deployment in your Airbrake project and auto-resolve any pre-existing development errors.

To generate the docs:

% bundle exec yardoc

To build the gem:

% bundle exec rake build

Contributors

Something went wrong with that request. Please try again.