Sha256: 89daed52a426d4edfc7d2a88c93f4a1260cc6bf05b56b36d7c3ceb72981a2aa4

Contents?: true

Size: 728 Bytes

Versions: 7

Compression:

Stored size: 728 Bytes

Contents

module Localeapp
  class ExceptionHandler
    def self.call(exception, locale, key_or_keys, options)
      keys = Array(key_or_keys).map { |key| ERB::Util.html_escape(key.to_s) }
      Localeapp.log(exception.message)
      # Which exact exception is set up by our i18n shims
      if exception.is_a? Localeapp::I18nMissingTranslationException
        Localeapp.log("Detected missing translation for key(s) #{keys.inspect}")

        keys.each do |key|
          Localeapp.missing_translations.add(locale, key, nil, options || {})
        end

        [locale, keys].join(', ')
      else
        Localeapp.log('Raising exception')
        raise
      end
    end
  end
end

I18n.exception_handler = Localeapp::ExceptionHandler

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
localeapp-2.4.0 lib/localeapp/exception_handler.rb
localeapp-2.3.0 lib/localeapp/exception_handler.rb
localeapp-2.2.0 lib/localeapp/exception_handler.rb
localeapp-2.1.1 lib/localeapp/exception_handler.rb
localeapp-2.1.0 lib/localeapp/exception_handler.rb
localeapp-2.0.0 lib/localeapp/exception_handler.rb
localeapp-1.0.2 lib/localeapp/exception_handler.rb