Fix error messages for reacting & listing errors
This commit is contained in:
parent
0db51536c5
commit
c8b6689a61
|
@ -8,7 +8,7 @@ class Ajax::SmileController < AjaxController
|
|||
current_user.smile answer
|
||||
rescue Errors::Base => e
|
||||
@response[:status] = e.code
|
||||
@response[:message] = e.locale_tag
|
||||
@response[:message] = I18n.t(e.locale_tag)
|
||||
return
|
||||
rescue => e
|
||||
Sentry.capture_exception(e)
|
||||
|
@ -50,7 +50,7 @@ class Ajax::SmileController < AjaxController
|
|||
current_user.smile_comment comment
|
||||
rescue Errors::Base => e
|
||||
@response[:status] = e.code
|
||||
@response[:message] = e.locale_tag
|
||||
@response[:message] = I18n.t(e.locale_tag)
|
||||
return
|
||||
rescue => e
|
||||
Sentry.capture_exception(e)
|
||||
|
|
|
@ -8,8 +8,12 @@ module Errors
|
|||
@code ||= self.class.name.sub('Errors::', '').underscore
|
||||
end
|
||||
|
||||
def locale_code
|
||||
code
|
||||
end
|
||||
|
||||
def locale_tag
|
||||
@locale_tag ||= "errors.#{code}"
|
||||
@locale_tag ||= "errors.#{locale_code}"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -81,19 +85,27 @@ module Errors
|
|||
end
|
||||
|
||||
class ReactingSelfBlockedOther < SelfBlockedOther
|
||||
@locale_tag = "errors.self_blocked_other"
|
||||
def locale_code
|
||||
"self_blocked_other"
|
||||
end
|
||||
end
|
||||
|
||||
class ReactingOtherBlockedSelf < OtherBlockedSelf
|
||||
@locale_tag = "errors.other_blocked_self"
|
||||
def locale_code
|
||||
"other_blocked_self"
|
||||
end
|
||||
end
|
||||
|
||||
class ListingSelfBlockedOther < SelfBlockedOther
|
||||
@locale_tag = "errors.self_blocked_other"
|
||||
def locale_code
|
||||
"self_blocked_other"
|
||||
end
|
||||
end
|
||||
|
||||
class ListingOtherBlockedSelf < OtherBlockedSelf
|
||||
@locale_tag = "errors.other_blocked_self"
|
||||
def locale_code
|
||||
"other_blocked_self"
|
||||
end
|
||||
end
|
||||
# endregion
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue