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

missing translation passes MissingTranslation instead MissingTranslationData #134

Closed
pivotalhalogen opened this issue Jan 11, 2012 · 5 comments
Milestone

Comments

@pivotalhalogen
Copy link

Given this (a more specific version of the suggestion from rails guides http://guides.rubyonrails.org/i18n.html#using-different-exception-handlers ):

module I18n
  def self.just_raise_that_exception(exception, locale, key, options)
    raise exception
  end
end

I18n.exception_handler = :just_raise_that_exception

and this test:

require 'spec_helper'

describe "MissingTranslationData" do
  it "should raise an error for missing translation" do
    expect {
      I18n.t('totally.bogus.translation.key')
    }.to raise_exception(I18n::MissingTranslationData)
  end
end

You get the following failure:

expected I18n::MissingTranslationData, got #<TypeError: exception class/object expected>

Because exception is I18n::MissingTranslation not I18n::MissingTranslationData and I18n::MissingTranslation does not inherit from an Exception class.

@henrik
Copy link
Contributor

henrik commented Feb 19, 2012

Also seeing this issue.

@pivotalhalogen
Copy link
Author

It's hard to tell from the code if this is a bug or the implementation has changed and the documentation is wrong.

@jpgeek
Copy link

jpgeek commented Oct 24, 2012

Seeing the same issue. Also, calling to_exception on a MissingTranslation instance returns a MissingTranslationData object, which IS an Exception.

@radar
Copy link
Collaborator

radar commented Nov 20, 2016

Thanks @pivotalhalogen. I can confirm that I can reproduce this issue. Taking a look.

@radar radar added this to the 0.8.0 milestone Nov 20, 2016
radar added a commit that referenced this issue Nov 20, 2016
Otherwise, attempting to re-raise this 'exception' will fail

See #134
@radar
Copy link
Collaborator

radar commented Nov 20, 2016

I have a fix for this in 1bcc77b. Thanks @pivotalhalogen and @henrik!

@radar radar closed this as completed Nov 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants