Added descriptive error messages
authorDaniel Kouřil <kouril@ics.muni.cz>
Thu, 2 Jun 2011 13:37:34 +0000 (13:37 +0000)
committerDaniel Kouřil <kouril@ics.muni.cz>
Thu, 2 Jun 2011 13:37:34 +0000 (13:37 +0000)
org.glite.px.proxyrenewal/src/common.c

index 70daeb0..4121a10 100644 (file)
 
 #ident "$Header$"
 
+static const char * const ErrorMsgs[] = {
+    "Connection closed unexpectedly",
+    "Generic error",
+    "Cannot parse protocol messages",
+    "Obligatory item not found in message",
+    "Unkown command",
+    "SSL error",
+    "MyProxy error",
+    "Proxy not registered",
+    "Proxy expired",
+    "VOMS error",
+    "Operation timed out",
+    "System error",
+};
+
 /* nread() and nwrite() never return partial data */
 static int
 nread(int sock, struct timeval *to, char *buf, size_t buf_len, size_t *read_len)
@@ -306,7 +321,11 @@ edg_wlpr_CleanResponse(edg_wlpr_Response *response)
 const char *
 edg_wlpr_GetErrorString(int code)
 {
-   return (code == 0) ? "OK" : "Error";
+    if (code == 0)
+       return "No error";
+    if (code <= EDG_WLPR_ERROR_BASE)
+       return strerror(code);
+    return ErrorMsgs[code - EDG_WLPR_ERROR_BASE - 1];
 }
 
 char *