about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-10-06 00:42:30 +0100
committerJames Booth <boothj5@gmail.com>2013-10-06 00:42:30 +0100
commit18b7def422e1347906304cdf0de0ba3601f7d411 (patch)
treed342a24a4ac3f2b2f5ede111ac9f6e0ebe6811cf
parent3dffc1d9ff5b7c334551282499dc06fbb1f8f80e (diff)
downloadprofani-tty-18b7def422e1347906304cdf0de0ba3601f7d411.tar.gz
Refactor error handling to use win_type switch
-rw-r--r--src/ui/core.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 2cb133b6..93fc74a0 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -405,17 +405,27 @@ ui_group_removed(const char * const contact, const char * const group)
 void
 ui_handle_error_message(const char * const from, const char * const err_msg)
 {
-    win_type_t win_type = ui_current_win_type();
     if (err_msg == NULL) {
         cons_show_error("Unknown error received from service.");
-    } else if (strcmp(err_msg, "conflict") == 0) {
-        if (win_type == WIN_MUC) {
-            ui_current_print_line("Nickname already in use.");
-        } else {
+    } else {
+        win_type_t win_type = ui_current_win_type();
+        gboolean handled = FALSE;
+
+        switch (win_type)
+        {
+            case WIN_MUC:
+                if (g_strcmp0(err_msg, "conflict") == 0) {
+                    ui_current_print_line("Nickname already in use.");
+                    handled = TRUE;
+                }
+                break;
+            default:
+                break;
+        }
+
+        if (handled != TRUE) {
             cons_show_error("Error received from server: %s", err_msg);
         }
-    } else {
-        cons_show_error("Error received from server: %s", err_msg);
     }
 
     ui_print_error_from_recipient(from, err_msg);