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:
Greg Campbell 2011-12-06 14:59:06 -08:00
Родитель 71943cfcbb
Коммит 3bc475ec6c
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -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