From 22b72d7680fda507b5cbb6bd6f8055196981b06b Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Mon, 14 Mar 2011 15:20:11 +0000 Subject: [PATCH] TC-88: Catching and reporting exceptions from commands instead of hanging Patch by Mimika Oh. git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3483 52acb1d6-8a22-11de-b505-999d5b087335 --- Programs/examples/TestClient/ClientManager.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Programs/examples/TestClient/ClientManager.cs b/Programs/examples/TestClient/ClientManager.cs index b3e86914..4f287a74 100644 --- a/Programs/examples/TestClient/ClientManager.cs +++ b/Programs/examples/TestClient/ClientManager.cs @@ -341,10 +341,17 @@ namespace OpenMetaverse.TestClient { TestClient testClient = (TestClient)state; if ((String.Empty == onlyAvatar) || (testClient.ToString() == onlyAvatar)) { - if (testClient.Commands.ContainsKey(firstToken)) - Logger.Log(testClient.Commands[firstToken].Execute(args, fromAgentID), - Helpers.LogLevel.Info, testClient); - else + if (testClient.Commands.ContainsKey(firstToken)) { + string result; + try { + result = testClient.Commands[firstToken].Execute(args, fromAgentID); + Logger.Log(result, Helpers.LogLevel.Info, testClient); + } catch(Exception e) { + Logger.Log(String.Format("{0} raised exception {1}", firstToken, e), + Helpers.LogLevel.Error, + testClient); + } + } else Logger.Log("Unknown command " + firstToken, Helpers.LogLevel.Warning); }