module I18n::Base
def handle_exception(handling, exception, locale, key, options)
I18n.exception_handler = I18nExceptionHandler.new # an object
I18n.exception_handler.call(exception, locale, key, options) # will be called like this
I18n.exception_handler = lambda { |*args| ... } # a lambda
I18n.custom_exception_handler(exception, locale, key, options) # will be called like this
I18n.exception_handler = :custom_exception_handler # this is the default
Examples:
method #call will be called on the exception_handler object.
a method call. A Proc will simply be called. In any other case the
If exception_handler is a Symbol then it will simply be sent to I18n as
be raised or thrown (MissingTranslation).
which can be a Symbol, a Proc or any other Object unless they're forced to
Any exceptions thrown in translate will be sent to the @@exception_handler
def handle_exception(handling, exception, locale, key, options) case handling when :raise raise exception.respond_to?(:to_exception) ? exception.to_exception : exception when :throw throw :exception, exception else case handler = options[:exception_handler] || config.exception_handler when Symbol send(handler, exception, locale, key, options) else handler.call(exception, locale, key, options) end end end