about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2018-03-23 21:09:48 +0220
committerPaul Fariello <paul@fariello.eu>2018-09-05 13:51:00 +0200
commit40eee1caabde94cc6bab82e9c583d4c1cc45c4c6 (patch)
tree73274dcf162cb62d348d20b3e28829acb4acc260 /src
parent925cd488c1397c960bc1eec0e441f073d887162e (diff)
downloadprofani-tty-40eee1caabde94cc6bab82e9c583d4c1cc45c4c6.tar.gz
Add command exec error handling
Diffstat (limited to 'src')
-rw-r--r--src/ui/ui.h1
-rw-r--r--src/ui/window.c15
-rw-r--r--src/xmpp/iq.c2
3 files changed, 17 insertions, 1 deletions
diff --git a/src/ui/ui.h b/src/ui/ui.h
index fa8f948a..6988d882 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -378,6 +378,7 @@ void win_clear(ProfWin *window);
 char* win_get_tab_identifier(ProfWin *window);
 char* win_to_string(ProfWin *window);
 void win_command_list_error(ProfWin *window, const char *const error);
+void win_command_exec_error(ProfWin *window, const char *const command, const char *const error, ...);
 void win_handle_command_list(ProfWin *window, GSList *cmds);
 void win_handle_command_exec_result_note(ProfWin *window, const char *const type, const char *const value);
 
diff --git a/src/ui/window.c b/src/ui/window.c
index f38127d7..a6f65d1b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1734,6 +1734,21 @@ win_command_list_error(ProfWin *window, const char *const error)
 }
 
 void
+win_command_exec_error(ProfWin *window, const char *const command, const char *const error, ...)
+{
+    assert(window != NULL);
+    va_list arg;
+    va_start(arg, error);
+    GString *msg = g_string_new(NULL);
+    g_string_vprintf(msg, error, arg);
+
+    win_println(window, THEME_ERROR, '!', "Error executing command %s: %s", command, msg);
+
+    g_string_free(msg, TRUE);
+    va_end(arg);
+}
+
+void
 win_handle_command_list(ProfWin *window, GSList *cmds)
 {
     assert(window != NULL);
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index 8702d1a1..dd856298 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1112,7 +1112,7 @@ _command_exec_response_handler(xmpp_stanza_t *const stanza, void *const userdata
         log_debug("Error executing command %s for %s: %s", command, from, error_message);
         ProfWin *win = wins_get_by_string(from);
         if (win) {
-            win_command_list_error(win, error_message);
+            win_command_exec_error(win, command, error_message);
         }
         free(error_message);
         free(from);