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

nil instead of raise #7

Open
AlexLarra opened this issue Jul 18, 2014 · 1 comment
Open

nil instead of raise #7

AlexLarra opened this issue Jul 18, 2014 · 1 comment

Comments

@AlexLarra
Copy link

Hi grosser,
I needed a list of languages translated in their own language and I used your gem. I did this helper.

def languages
  languages = {}

  I18nData.languages.each do |code, language|
    begin
      languages.merge!(I18nData.languages(code)[code] => code.downcase)
    rescue Exception => e
      languages.merge!(I18nData.languages('EN')[code] => code.downcase)
    end
  end
  languages
end

It would better not to work with rescue but there it is this line that uses raises instead of return nil:

raise NoTranslationAvailable, "#{type}-#{language_code}"

Wouldn't be better to use nil?

Thank you for your gem

@grosser
Copy link
Owner

grosser commented Jul 19, 2014

sounds like a good idea, can you make this a PR ?

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