зеркало из https://github.com/github/memcached.git
Handle unexpected return codes
Previously, these would throw a TypeError because of an attempt to raise nil, which was a little confusing. This implementation should make them easier to track.
This commit is contained in:
Родитель
71943cfcbb
Коммит
3bc475ec6c
|
@ -610,7 +610,11 @@ Please note that when <tt>:no_block => true</tt>, update methods do not raise on
|
|||
end
|
||||
end
|
||||
end
|
||||
if EXCEPTIONS[ret]
|
||||
raise EXCEPTIONS[ret], message
|
||||
else
|
||||
raise Memcached::Error, "Unknown return code: #{ret}"
|
||||
end
|
||||
end
|
||||
|
||||
# Turn an array of keys into a hash of keys to servers.
|
||||
|
|
|
@ -1279,6 +1279,14 @@ class MemcachedTest < Test::Unit::TestCase
|
|||
@cache.instance_variable_get("@struct")
|
||||
end
|
||||
|
||||
# NOTE: This breaks encapsulation, but there's no other easy way to test this without
|
||||
# mocking out Rlibmemcached calls
|
||||
def test_reraise_invalid_return_code
|
||||
assert_raise Memcached::Error do
|
||||
@cache.send(:check_return_code, 5000)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def key
|
||||
|
|
Загрузка…
Ссылка в новой задаче