Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid locale in CarrierWave::MiniMagick#manipulate! #1977

Closed
paweljw opened this issue Jun 23, 2016 · 1 comment
Closed

Invalid locale in CarrierWave::MiniMagick#manipulate! #1977

paweljw opened this issue Jun 23, 2016 · 1 comment

Comments

@paweljw
Copy link

paweljw commented Jun 23, 2016

If a MiniMagick::Error or a MiniMagick::Invalid exception is raised within manipulate!, the rescue block will try to find a default error message with

I18n.translate(:"errors.messages.mini_magick_processing_error", e: e, locale: :en)

If the :en locale is not included in an application's locales, which is my case, an I18n::InvalidLocale exception will be raised within the rescue block, effectively blocking the developer from gaining insight into what actual exception has occured.

I'm currently using this as a workaround:

rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
  default = if I18n.available_locales.include?(:en)
              I18n.translate(:"errors.messages.mini_magick_processing_error", e: e, locale: :en)
            else
              ''
            end
  message = I18n.translate(:"errors.messages.mini_magick_processing_error", e: e, default: default)
  raise CarrierWave::ProcessingError, message
end

But it's rather specific to my use case and far from perfect for general usage. However, the current implementation is also not perfect in the edge case of apps that do not have a :en locale.

kryzhovnik added a commit to kryzhovnik/carrierwave that referenced this issue Dec 16, 2016
…gick#manipulate!

Since ([commit on May 9, 2014](ruby-i18n/i18n@b5703d7)) enforce_available_locales in I18n is true by default, the aproach which implies on default error messages from `:en` locale is broked for all apps where `:en` is not available locale.
mshibuya added a commit that referenced this issue Mar 5, 2017
Fixing #1977 Invalid locale in CarrierWave::MiniMagick#manipulate!
@mshibuya
Copy link
Member

mshibuya commented Mar 5, 2017

Dup of #1729, and fixed by #2083.

@mshibuya mshibuya closed this as completed Mar 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants