mirror of
https://github.com/samsonjs/http-cookie.git
synced 2026-04-27 14:57:46 +00:00
1.8 compatibility; Use IndexError instead of KeyError.
This commit is contained in:
parent
05e5d332df
commit
59ddb58b25
2 changed files with 8 additions and 8 deletions
|
|
@ -6,15 +6,15 @@ class HTTP::CookieJar::AbstractSaver
|
||||||
|
|
||||||
# Gets an implementation class by the name, optionally trying to
|
# Gets an implementation class by the name, optionally trying to
|
||||||
# load "http/cookie_jar/*_saver" if not found. If loading fails,
|
# load "http/cookie_jar/*_saver" if not found. If loading fails,
|
||||||
# KeyError is raised.
|
# IndexError is raised.
|
||||||
def implementation(symbol)
|
def implementation(symbol)
|
||||||
@@class_map.fetch(symbol)
|
@@class_map.fetch(symbol)
|
||||||
rescue KeyError
|
rescue IndexError
|
||||||
begin
|
begin
|
||||||
require 'http/cookie_jar/%s_saver' % symbol
|
require 'http/cookie_jar/%s_saver' % symbol
|
||||||
@@class_map.fetch(symbol)
|
@@class_map.fetch(symbol)
|
||||||
rescue LoadError, KeyError => e
|
rescue LoadError, IndexError => e
|
||||||
raise KeyError, 'cookie saver unavailable: %s' % symbol.inspect
|
raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@ class HTTP::CookieJar::AbstractStore
|
||||||
|
|
||||||
# Gets an implementation class by the name, optionally trying to
|
# Gets an implementation class by the name, optionally trying to
|
||||||
# load "http/cookie_jar/*_store" if not found. If loading fails,
|
# load "http/cookie_jar/*_store" if not found. If loading fails,
|
||||||
# KeyError is raised.
|
# IndexError is raised.
|
||||||
def implementation(symbol)
|
def implementation(symbol)
|
||||||
@@class_map.fetch(symbol)
|
@@class_map.fetch(symbol)
|
||||||
rescue KeyError
|
rescue IndexError
|
||||||
begin
|
begin
|
||||||
require 'http/cookie_jar/%s_store' % symbol
|
require 'http/cookie_jar/%s_store' % symbol
|
||||||
@@class_map.fetch(symbol)
|
@@class_map.fetch(symbol)
|
||||||
rescue LoadError, KeyError => e
|
rescue LoadError, IndexError => e
|
||||||
raise KeyError, 'cookie store unavailable: %s' % symbol.inspect
|
raise IndexError, 'cookie store unavailable: %s' % symbol.inspect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue