From c8b9ce128fdb9b63c323749ed495150f87e29b52 Mon Sep 17 00:00:00 2001 From: hchen2020 <101423@smsassist.com> Date: Thu, 24 Aug 2023 07:12:27 -0500 Subject: [PATCH] Catch and log function call error. --- .../Services/ConversationService.CallFunctions.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs index b02f3d03..66f0a25d 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.CallFunctions.cs @@ -29,9 +29,17 @@ public partial class ConversationService await hook.OnFunctionExecuting(msg); } - // Execute function - await fn.Execute(msg); - + try + { + // Execute function + await fn.Execute(msg); + } + catch (Exception ex) + { + msg.ExecutionResult = ex.Message; + _logger.LogError(msg.ExecutionResult); + } + // After functions have been executed foreach (var hook in hooks) {