1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix code sample for custom exception handler [ci skip]

This commit is contained in:
Bart 2015-02-19 15:12:44 +01:00 committed by Bart de Water
parent 259d33db8c
commit c2f59f37c6

View file

@ -1030,7 +1030,7 @@ In other contexts you might want to change this behavior, though. E.g. the defau
module I18n
class JustRaiseExceptionHandler < ExceptionHandler
def call(exception, locale, key, options)
if exception.is_a?(MissingTranslation)
if exception.is_a?(MissingTranslationData)
raise exception.to_exception
else
super
@ -1047,7 +1047,7 @@ This would re-raise only the `MissingTranslationData` exception, passing all oth
However, if you are using `I18n::Backend::Pluralization` this handler will also raise `I18n::MissingTranslationData: translation missing: en.i18n.plural.rule` exception that should normally be ignored to fall back to the default pluralization rule for English locale. To avoid this you may use additional check for translation key:
```ruby
if exception.is_a?(MissingTranslation) && key.to_s != 'i18n.plural.rule'
if exception.is_a?(MissingTranslationData) && key.to_s != 'i18n.plural.rule'
raise exception.to_exception
else
super