charliesome/better_errors — pull request #212 by christophermanning (2013-10-29 21:13:36+00:00)
Title: Don't crash when original_exception is nil

Check that exception.orignal_exception is an exception if the exception respond_to? :orignal_exception

[Certain exception types](http://api.rubyonrails.org/classes/ActiveRecord/StatementInvalid.html) respond_to? original_exception, but [the value may not be set](
https://github.com/rails/rails/blob/df2226ea16922fd4e2ea72b8ee372a4cb5621114/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb#L499)
and it would cause an [undefined method message for nil class exception in better_errors](https://github.com/charliesome/better_errors/blob/3be2c834e8a644cfd5436f0b107c70d713f46de6/lib/better_errors/middleware.rb#L118).