@Kevin
Thanks for your help, now the code above can run successfully
I still have a question:
If the function func3 includes 100 lines Or more of code, I need to implement:
1.when any line of code error occurs, automatically write the error information and the line number where the code is located to the "$desktop$\err_log.txt" file on the desktop. (I don't want to add error handling after each line of code.)
2.The dialog does not crash or close when any error occurs
is it possible? Can I implement an error handling method similar to C#? eg: Try ……catch……finally
Thanks for your help, now the code above can run successfully

I still have a question:
If the function func3 includes 100 lines Or more of code, I need to implement:
1.when any line of code error occurs, automatically write the error information and the line number where the code is located to the "$desktop$\err_log.txt" file on the desktop. (I don't want to add error handling after each line of code.)
2.The dialog does not crash or close when any error occurs
is it possible? Can I implement an error handling method similar to C#? eg: Try ……catch……finally
