1.8 compatibility; Use IndexError instead of KeyError.

This commit is contained in:
Akinori MUSHA 2013-03-15 12:11:38 +09:00
parent 05e5d332df
commit 59ddb58b25
2 changed files with 8 additions and 8 deletions

View file

@ -6,15 +6,15 @@ class HTTP::CookieJar::AbstractSaver
# Gets an implementation class by the name, optionally trying to
# load "http/cookie_jar/*_saver" if not found. If loading fails,
# KeyError is raised.
# IndexError is raised.
def implementation(symbol)
@@class_map.fetch(symbol)
rescue KeyError
rescue IndexError
begin
require 'http/cookie_jar/%s_saver' % symbol
@@class_map.fetch(symbol)
rescue LoadError, KeyError => e
raise KeyError, 'cookie saver unavailable: %s' % symbol.inspect
rescue LoadError, IndexError => e
raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
end
end

View file

@ -6,15 +6,15 @@ class HTTP::CookieJar::AbstractStore
# Gets an implementation class by the name, optionally trying to
# load "http/cookie_jar/*_store" if not found. If loading fails,
# KeyError is raised.
# IndexError is raised.
def implementation(symbol)
@@class_map.fetch(symbol)
rescue KeyError
rescue IndexError
begin
require 'http/cookie_jar/%s_store' % symbol
@@class_map.fetch(symbol)
rescue LoadError, KeyError => e
raise KeyError, 'cookie store unavailable: %s' % symbol.inspect
rescue LoadError, IndexError => e
raise IndexError, 'cookie store unavailable: %s' % symbol.inspect
end
end