Skip to content

Commit 4a220ab

Browse files
fix comments
1 parent a2cae37 commit 4a220ab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Infrastructure/BotSharp.Core.Crontab/Functions/TaskWaitFn.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Linq;
66
using System.Text;
7+
using System.Text.Json.Serialization;
78
using System.Threading.Tasks;
89

910
namespace BotSharp.Core.Crontab.Functions;
@@ -22,12 +23,17 @@ public async Task<bool> Execute(RoleDialogModel message)
2223
try
2324
{
2425
var args = JsonSerializer.Deserialize<TaskWaitArgs>(message.FunctionArgs);
25-
if (args != null || args.DelayTime > 0)
26+
if (args != null && args.DelayTime > 0)
2627
{
2728
await Task.Delay(args.DelayTime * 1000);
2829
}
2930
message.Content = "wait task completed";
3031
}
32+
catch (JsonException jsonEx)
33+
{
34+
message.Content = "Invalid function arguments format.";
35+
_logger.LogError(jsonEx, "Json deserialization failed.");
36+
}
3137
catch (Exception ex)
3238
{
3339
message.Content = "Unable to perform delay task";

0 commit comments

Comments
 (0)