Skip to content

Commit

Permalink
KeyError is an IndexError in 1.9, only include if not already defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Jul 8, 2009
1 parent b8eef6e commit 3dfc976
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/i18n/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
class KeyError < IndexError
def initialize(message = nil)
super(message || "key not found")
end
end unless defined?(KeyError)

module I18n
class ArgumentError < ::ArgumentError; end

Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
license terms as Ruby.
=end

class KeyError < Exception
class KeyError < IndexError
def initialize(message = nil)
super(message || "key not found")
end
end
end unless defined?(KeyError)

# Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError.
#
Expand Down

0 comments on commit 3dfc976

Please sign in to comment.