Permalink
Browse files

Merge pull request #14 from thomasjachmann/master

improve exception handling for exceptions that implement to_hash
  • Loading branch information...
2 parents 86c898b + 477bbb5 commit e000eb9f29b6e0276dff349203364e70697d55de @usiegj00 usiegj00 committed Oct 9, 2011
Showing with 15 additions and 5 deletions.
  1. +2 −5 lib/airbrake.rb
  2. +13 −0 test/notifier_test.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
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

0 comments on commit e000eb9

Please sign in to comment.