7b3a9df34c79863685000d24820116fd240fbb35
[m6w6/libmemcached] / src / libmemcached / strerror.cc
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Libmemcached library
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 * Copyright (C) 2006-2009 Brian Aker All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
22 * written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 */
37
38 #include "libmemcached/common.h"
39
40 const char *memcached_strerror(const memcached_st *, memcached_return_t rc)
41 {
42 switch (rc)
43 {
44 case MEMCACHED_SUCCESS:
45 return "SUCCESS";
46
47 case MEMCACHED_FAILURE:
48 return "FAILURE";
49
50 case MEMCACHED_HOST_LOOKUP_FAILURE: // getaddrinfo only
51 return "getaddrinfo() or getnameinfo() HOSTNAME LOOKUP FAILURE";
52
53 case MEMCACHED_CONNECTION_FAILURE:
54 return "CONNECTION FAILURE";
55
56 case MEMCACHED_CONNECTION_BIND_FAILURE: // DEPRECATED, see MEMCACHED_HOST_LOOKUP_FAILURE
57 return "CONNECTION BIND FAILURE";
58
59 case MEMCACHED_READ_FAILURE:
60 return "READ FAILURE";
61
62 case MEMCACHED_UNKNOWN_READ_FAILURE:
63 return "UNKNOWN READ FAILURE";
64
65 case MEMCACHED_PROTOCOL_ERROR:
66 return "PROTOCOL ERROR";
67
68 case MEMCACHED_CLIENT_ERROR:
69 return "CLIENT ERROR";
70
71 case MEMCACHED_SERVER_ERROR:
72 return "SERVER ERROR";
73
74 case MEMCACHED_WRITE_FAILURE:
75 return "WRITE FAILURE";
76
77 case MEMCACHED_ERROR:
78 return "ERROR was returned by server";
79
80 case MEMCACHED_DATA_EXISTS:
81 return "CONNECTION DATA EXISTS";
82
83 case MEMCACHED_DATA_DOES_NOT_EXIST:
84 return "CONNECTION DATA DOES NOT EXIST";
85
86 case MEMCACHED_NOTSTORED:
87 return "NOT STORED";
88
89 case MEMCACHED_STORED:
90 return "STORED";
91
92 case MEMCACHED_NOTFOUND:
93 return "NOT FOUND";
94
95 case MEMCACHED_MEMORY_ALLOCATION_FAILURE:
96 return "MEMORY ALLOCATION FAILURE";
97
98 case MEMCACHED_PARTIAL_READ:
99 return "PARTIAL READ";
100
101 case MEMCACHED_SOME_ERRORS:
102 return "SOME ERRORS WERE REPORTED";
103
104 case MEMCACHED_NO_SERVERS:
105 return "NO SERVERS DEFINED";
106
107 case MEMCACHED_END:
108 return "SERVER END";
109
110 case MEMCACHED_DELETED:
111 return "SERVER DELETE";
112
113 case MEMCACHED_VALUE:
114 return "SERVER VALUE";
115
116 case MEMCACHED_STAT:
117 return "STAT VALUE";
118
119 case MEMCACHED_ITEM:
120 return "ITEM VALUE";
121
122 case MEMCACHED_ERRNO:
123 return "SYSTEM ERROR";
124
125 case MEMCACHED_FAIL_UNIX_SOCKET:
126 return "COULD NOT OPEN UNIX SOCKET";
127
128 case MEMCACHED_NOT_SUPPORTED:
129 return "ACTION NOT SUPPORTED";
130
131 case MEMCACHED_FETCH_NOTFINISHED:
132 return "FETCH WAS NOT COMPLETED";
133
134 case MEMCACHED_NO_KEY_PROVIDED:
135 return "A KEY LENGTH OF ZERO WAS PROVIDED";
136
137 case MEMCACHED_BUFFERED:
138 return "ACTION QUEUED";
139
140 case MEMCACHED_TIMEOUT:
141 return "A TIMEOUT OCCURRED";
142
143 case MEMCACHED_BAD_KEY_PROVIDED:
144 return "A BAD KEY WAS PROVIDED/CHARACTERS OUT OF RANGE";
145
146 case MEMCACHED_INVALID_HOST_PROTOCOL:
147 return "THE HOST TRANSPORT PROTOCOL DOES NOT MATCH THAT OF THE CLIENT";
148
149 case MEMCACHED_SERVER_MARKED_DEAD:
150 return "SERVER IS MARKED DEAD";
151
152 case MEMCACHED_UNKNOWN_STAT_KEY:
153 return "ENCOUNTERED AN UNKNOWN STAT KEY";
154
155 case MEMCACHED_E2BIG:
156 return "ITEM TOO BIG";
157
158 case MEMCACHED_INVALID_ARGUMENTS:
159 return "INVALID ARGUMENTS";
160
161 case MEMCACHED_KEY_TOO_BIG:
162 return "KEY RETURNED FROM SERVER WAS TOO LARGE";
163
164 case MEMCACHED_AUTH_PROBLEM:
165 return "FAILED TO SEND AUTHENTICATION TO SERVER";
166
167 case MEMCACHED_AUTH_FAILURE:
168 return "AUTHENTICATION FAILURE";
169
170 case MEMCACHED_AUTH_CONTINUE:
171 return "CONTINUE AUTHENTICATION";
172
173 case MEMCACHED_PARSE_ERROR:
174 return "ERROR OCCURED WHILE PARSING";
175
176 case MEMCACHED_PARSE_USER_ERROR:
177 return "USER INITIATED ERROR OCCURED WHILE PARSING";
178
179 case MEMCACHED_DEPRECATED:
180 return "DEPRECATED";
181
182 case MEMCACHED_IN_PROGRESS:
183 return "OPERATION IN PROCESS";
184
185 case MEMCACHED_SERVER_TEMPORARILY_DISABLED:
186 return "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY";
187
188 case MEMCACHED_SERVER_MEMORY_ALLOCATION_FAILURE:
189 return "SERVER FAILED TO ALLOCATE OBJECT";
190
191 case MEMCACHED_UNIX_SOCKET_PATH_TOO_BIG:
192 return "UNIX SOCKET PATH TOO LARGE";
193
194 default:
195 case MEMCACHED_MAXIMUM_RETURN:
196 return "INVALID memcached_return_t";
197 }
198 }