MindscapeHQ/raygun4ruby — pull request #48 by nickmalcolm (2014-10-01 22:32:11+00:00)
Title: Handle exceptions which return a nil message

Raygun can't track errors whose `.message` returns `nil`. Calling `.to_s` before encoding the message in the `error_details` method fixes this.

The added test is kinda gross, sorry.

E.g. The Evernote gem can throw errors which, for reasons unknown, has `nil` for the message. Other gems could probably do the same thing, and it'd be good for Raygun to handle this case.

2.1.1 :005 > t = Thrift::Exception.new(nil)
=> #
2.1.1 :006 > t.message
=> nil
2.1.1 :015 > Raygun.track_exception(t)
NoMethodError: undefined method `encode' for nil:NilClass
from /Users/nickmalcolm/.rvm/gems/ruby-2.1.1/gems/raygun4ruby-1.0.1/lib/raygun/client.rb:38:in `error_details'
from /Users/nickmalcolm/.rvm/gems/ruby-2.1.1/gems/raygun4ruby-1.0.1/lib/raygun/client.rb:113:in `build_payload_hash'
from /Users/nickmalcolm/.rvm/gems/ruby-2.1.1/gems/raygun4ruby-1.0.1/lib/raygun/client.rb:22:in `track_exception'
from /Users/nickmalcolm/.rvm/gems/ruby-2.1.1/gems/raygun4ruby-1.0.1/lib/raygun.rb:44:in `track_exception'

Evernote's exception class: https://github.com/evernote/evernote-sdk-ruby/blob/master/lib/thrift/exceptions.rb