File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/Infrastructure/BotSharp.Core.Crontab/Functions Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 44using System . Collections . Generic ;
55using System . Linq ;
66using System . Text ;
7+ using System . Text . Json . Serialization ;
78using System . Threading . Tasks ;
89
910namespace 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" ;
You can’t perform that action at this time.
0 commit comments