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