From f80edb63210c3a84e640610fce1ce953296ca111 Mon Sep 17 00:00:00 2001 From: Evan Weaver Date: Tue, 20 Oct 2009 18:47:37 -0700 Subject: [PATCH] Better error in stats. --- lib/memcached/memcached.rb | 4 ++++ test/unit/memcached_test.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/memcached/memcached.rb b/lib/memcached/memcached.rb index 34a8e5d..eb33b77 100644 --- a/lib/memcached/memcached.rb +++ b/lib/memcached/memcached.rb @@ -409,6 +409,10 @@ Please note that when pipelining is enabled, setter and deleter methods do not r Lib.memcached_stat_free(@struct, stat_struct) stats + rescue Memcached::SomeErrorsWereReported => _ + e = _.class.new("Error getting stats") + e.set_backtrace(_.backtrace) + raise e end ### Operations helpers diff --git a/test/unit/memcached_test.rb b/test/unit/memcached_test.rb index 375b0c3..046ab96 100644 --- a/test/unit/memcached_test.rb +++ b/test/unit/memcached_test.rb @@ -746,6 +746,11 @@ class MemcachedTest < Test::Unit::TestCase assert_instance_of String, stats[:version].first end + def test_missing_stats + cache = Memcached.new('localhost:43041') + assert_raises(Memcached::SomeErrorsWereReported) { cache.stats } + end + # Clone def test_clone