Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #12888 - handle non-record exceptions #5673

Merged
merged 1 commit into from
Dec 21, 2015

Conversation

jlsherrill
Copy link
Member

No description provided.

@jlsherrill jlsherrill changed the title Fixes 12888 - handle non-record exceptions Fixes #12888 - handle non-record exceptions Dec 20, 2015
@@ -118,7 +118,7 @@ def respond_for_exception(exception, options = {})
:text => exception.message,
:display_message => exception.message)

options[:errors] = exception.respond_to?(:record) ? exception.record.errors : [exception.message]
options[:errors] = exception.try(:record).try(:errors) ? exception.record.errors : [exception.message]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is simpler:

options[:errors] = exception.try(:record).try(:errors) || [exception.message]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@daviddavis
Copy link
Contributor

ACK pending small comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants