2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-21 19:11:18 +08:00

Show the reason the topic couldn't be split rather than a generic error.

This commit is contained in:
Robin Ward 2014-08-11 14:42:50 -04:00
parent e564614b70
commit 21185617b0
3 changed files with 17 additions and 2 deletions

View file

@ -5,6 +5,9 @@ module JsonError
# If we're passed a string, assume that is the error message
return {errors: [obj]} if obj.is_a?(String)
# If it's an AR exception target the record
obj = obj.record if obj.is_a?(ActiveRecord::RecordInvalid)
# If it looks like an activerecord object, extract its messages
return {errors: obj.errors.full_messages } if obj.respond_to?(:errors) && obj.errors.present?