Abstraction (which will save us merge hell with 1.2).
[awesomized/libmemcached] / libmemcached / response.cc
index 67b0999f7f2afff67e462ec9c2c5a4894577aea8..cf7ed41e6936492c0d6c44c3532b4cfdfb74b646 100644 (file)
@@ -416,7 +416,17 @@ static memcached_return_t textual_read_one_response(org::libmemcached::Instance*
           and buffer[6] == '_'
           and buffer[7] == 'E' and buffer[8] == 'R' and buffer[9] == 'R' and buffer[10] == 'O' and buffer[11] == 'R')
       {
-        return MEMCACHED_CLIENT_ERROR;
+        // Move past the basic error message and whitespace
+        char *startptr= buffer + memcached_literal_param_size("CLIENT_ERROR");
+        if (startptr[0] == ' ')
+        {
+          startptr++;
+        }
+
+        char *endptr= startptr;
+        while (*endptr != '\r' && *endptr != '\n') endptr++;
+
+        return memcached_set_error(*instance, MEMCACHED_CLIENT_ERROR, MEMCACHED_AT, startptr, size_t(endptr - startptr));
       }
     }
     break;
@@ -795,7 +805,7 @@ static memcached_return_t _read_one_response(org::libmemcached::Instance* instan
 
   if (result == NULL)
   {
-    memcached_st *root= (memcached_st *)instance->root;
+    Memcached *root= (Memcached *)instance->root;
     result = &root->result;
   }