From 4a220ab2cdc304f19f76006c0a1b46c87e2f17c2 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Wed, 30 Apr 2025 09:11:22 -0500 Subject: [PATCH] fix comments --- .../BotSharp.Core.Crontab/Functions/TaskWaitFn.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Functions/TaskWaitFn.cs b/src/Infrastructure/BotSharp.Core.Crontab/Functions/TaskWaitFn.cs index b4e63a76..0fb68dc9 100644 --- a/src/Infrastructure/BotSharp.Core.Crontab/Functions/TaskWaitFn.cs +++ b/src/Infrastructure/BotSharp.Core.Crontab/Functions/TaskWaitFn.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace BotSharp.Core.Crontab.Functions; @@ -22,12 +23,17 @@ public class TaskWaitFn : IFunctionCallback try { var args = JsonSerializer.Deserialize(message.FunctionArgs); - if (args != null || args.DelayTime > 0) + if (args != null && args.DelayTime > 0) { await Task.Delay(args.DelayTime * 1000); } message.Content = "wait task completed"; } + catch (JsonException jsonEx) + { + message.Content = "Invalid function arguments format."; + _logger.LogError(jsonEx, "Json deserialization failed."); + } catch (Exception ex) { message.Content = "Unable to perform delay task";