[smuxi: 1/5] Engine: bring errors from server.OnConnectCommands to the UI



commit aba9e8f9395c4c6fd879d65d99f373ee0de81ea5
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Wed Jan 28 21:07:19 2015 +0100

    Engine: bring errors from server.OnConnectCommands to the UI
    
    If the commands to be executed on server connection were to throw
    any exception, they were being swallowed and not shown in the UI,
    so the user could never notice that there was a problem with them
    (for example, having a /timeline command to inspect a Twitter user
    that doesn't exist, would not yield any visible problem).

 src/Engine/Session.cs |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/src/Engine/Session.cs b/src/Engine/Session.cs
index 9a7fe9e..4a418a0 100644
--- a/src/Engine/Session.cs
+++ b/src/Engine/Session.cs
@@ -1514,13 +1514,25 @@ namespace Smuxi.Engine
                                 if (command.Length == 0) {
                                     continue;
                                 }
-                                CommandModel cd = new CommandModel(
-                                    frontendManager,
-                                    protocolManager.Chat,
-                                    (string) _UserConfig["Interface/Entry/CommandCharacter"],
-                                    command
-                                );
-                                protocolManager.Command(cd);
+
+                                try {
+                                    var cd = new CommandModel(
+                                        frontendManager,
+                                        protocolManager.Chat,
+                                        (string) _UserConfig["Interface/Entry/CommandCharacter"],
+                                        command
+                                    );
+                                    protocolManager.Command(cd);
+                                } catch (Exception ex) {
+#if LOG4NET
+                                    f_Logger.Error("Command in Connected event: Exception", ex);
+#endif
+                                    var msg = CreateMessageBuilder().
+                                        AppendErrorText("Command '{0}' failed. Reason: {1} ({2})",
+                                                        command, ex.Message).
+                                        ToMessage();
+                                    AddMessageToFrontend (frontendManager, protocolManager.Chat, msg);
+                                }
                             }
                         } catch (Exception ex) {
 #if LOG4NET


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]