changeset 481:73a648387d10

Improve error reporting.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 26 May 2012 08:40:37 +0300
parents cb83967a0d9d
children 8bd6bad09fb8
files main.c
diffstat 1 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Sat May 26 08:19:09 2012 +0300
+++ b/main.c	Sat May 26 08:40:37 2012 +0300
@@ -362,12 +362,17 @@
 
     // Decode message string
     msg = nn_decode_str1(msg);
-    if (!msg) return -1;
+    if (!msg)
+    {
+        errorMsg("Decode/malloc failure @ nnproto_parse_user()\n");
+        return -1;
+    }
 
     // Decode username
     name = nn_decode_str1(name);
     if (!name)
     {
+        errorMsg("Decode/malloc failure @ nnproto_parse_user()\n");
         th_free(msg);
         return -2;
     }
@@ -488,7 +493,11 @@
     *s = 0;
 
     p = nn_dbldecode_str(str);
-    if (!p) return -1;
+    if (!p)
+    {
+        errorMsg("Decode/malloc failure @ nnproto_parse_add_user()\n");
+        return -1;
+    }
 
     win = nnwin_find(p);
     nn_userhash_insert(nnUsers, nn_username_encode(p));
@@ -512,7 +521,11 @@
     *s = 0;
 
     p = nn_dbldecode_str(str);
-    if (!p) return -1;
+    if (!p)
+    {
+        errorMsg("Decode/malloc failure @ nnproto_parse_delete_user()\n");
+        return -1;
+    }
 
     win = nnwin_find(p);
     nn_userhash_delete(nnUsers, nn_username_encode(p));
@@ -1565,11 +1578,7 @@
                     nn_conn_buf_skip(conn, strlen(conn->ptr) + 1);
                 }
                 else
-                {
-                    // Fatal error, quit
-                    errorMsg("Fatal error with message: %s\n", conn->ptr);
                     isError = TRUE;
-                }
             }
         }
         else