Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #14 from thomasjachmann/master

improve exception handling for exceptions that implement to_hash
  • Loading branch information...
commit e000eb9f29b6e0276dff349203364e70697d55de 2 parents 86c898b + 477bbb5
Jonathan Siegel usiegj00 authored
Showing with 15 additions and 5 deletions.
  1. +2 −5 lib/airbrake.rb
  2. +13 −0 test/notifier_test.rb
7 lib/airbrake.rb
View
@@ -137,11 +137,8 @@ def send_notice(notice)
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
+ opts = opts.merge(:exception => exception)
+ opts = opts.merge(exception.to_hash) if exception.respond_to?(:to_hash)
Notice.new(configuration.merge(opts))
end
13 test/notifier_test.rb
View
@@ -82,6 +82,19 @@ def set_development_env
assert_sent(notice, notice_args)
end
+ should "create and send a notice for an exception that responds to to_hash" do
+ set_public_env
+ exception = build_exception
+ notice = stub_notice!
+ notice_args = { :error_message => 'uh oh' }
+ exception.stubs(:to_hash).returns(notice_args)
+ stub_sender!
+
+ Airbrake.notify(exception)
+
+ assert_sent(notice, notice_args.merge(:exception => exception))
+ end
+
should "create and sent a notice for an exception and hash" do
set_public_env
exception = build_exception
Please sign in to comment.
Something went wrong with that request. Please try again.