From f814bf90a3e60b70688edfafec4a850400a8a9ac Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 30 Jul 2011 11:58:49 -0700 Subject: [PATCH] Expand error for incorrect report. --- libmemcached/error.cc | 7 ++++++- libmemcached/response.cc | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 5afb2282..b0bdd3f8 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -495,10 +495,15 @@ memcached_error_t *memcached_error_copy(const memcached_server_st& server) memcached_return_t memcached_server_error_return(memcached_server_instance_st ptr) { + if (ptr == NULL) + { + return MEMCACHED_INVALID_ARGUMENTS; + } + if (ptr and ptr->error_messages) { return ptr->error_messages->rc; } - return MEMCACHED_FAILURE; + return MEMCACHED_SUCCESS; } diff --git a/libmemcached/response.cc b/libmemcached/response.cc index dddcb349..74d10a96 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -613,24 +613,31 @@ static memcached_return_t binary_read_one_response(memcached_server_write_instan case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT: rc= MEMCACHED_NOTFOUND; break; + case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS: rc= MEMCACHED_DATA_EXISTS; break; + case PROTOCOL_BINARY_RESPONSE_NOT_STORED: rc= MEMCACHED_NOTSTORED; break; + case PROTOCOL_BINARY_RESPONSE_E2BIG: rc= MEMCACHED_E2BIG; break; + case PROTOCOL_BINARY_RESPONSE_ENOMEM: rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE; break; + case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE: rc= MEMCACHED_AUTH_CONTINUE; break; + case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR: rc= MEMCACHED_AUTH_FAILURE; break; + case PROTOCOL_BINARY_RESPONSE_EINVAL: case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND: default: -- 2.30.2