Fix error messages for reacting & listing errors

This commit is contained in:
Karina Kwiatek 2022-06-13 11:48:49 +02:00 committed by Karina Kwiatek
parent 0db51536c5
commit c8b6689a61
2 changed files with 19 additions and 7 deletions

View File

@ -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)

View File

@ -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