src/error.c
changeset 6 240ae8482d64
child 7 844f014409ff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/error.c	Sun Feb 22 07:21:28 2009 +0200
@@ -0,0 +1,28 @@
+
+#include "error.h"
+
+/*
+ * Helper macros
+ */
+#define ERROR_NAME(code, name) case code: return name
+
+const char *error_name (err_t code)
+{
+    switch (code) {
+        ERROR_NAME( ERR_CALLOC,                         "calloc"                                        );
+        ERROR_NAME( ERR_GETADDRINFO,                    "getaddrinfo"                                   );
+        ERROR_NAME( ERR_GETADDRINFO_EMPTY,              "getaddrinfo"                                   );
+        ERROR_NAME( ERR_SOCKET,                         "socket"                                        );
+        ERROR_NAME( ERR_CONNECT,                        "connect"                                       );
+        ERROR_NAME( ERR_READ,                           "read"                                          );
+        ERROR_NAME( ERR_WRITE,                          "write"                                         );
+        ERROR_NAME( ERR_GNUTLS_CERT_ALLOC_CRED,         "gnutls_certificate_allocate_credentials"       );
+        ERROR_NAME( ERR_GNUTLS_GLOBAL_INIT,             "gnutls_global_init"                            );
+        ERROR_NAME( ERR_GNUTLS_INIT,                    "gnutls_init"                                   );
+        ERROR_NAME( ERR_GNUTLS_SET_DEFAULT_PRIORITY,    "gnutls_set_default_priority"                   );
+        ERROR_NAME( ERR_GNUTLS_CRED_SET,                "gnutls_credentials_set"                        );
+        ERROR_NAME( ERR_GNUTLS_HANDSHAKE,               "gnutls_handshake"                              );
+        default: return "[unknown]";
+    }
+}
+