Skip to main content

Try-to-Execute-and-Can-Retry-N-Times.-If-an-Exception-Occurs-after-Retry,-Then-It-Will-Be-Handled

Command Description

Use try-catch to handle code blocks that might throw an error

Command Prototype

Try count 

Catch Ex

End Try

Parameter Description

ParameterRequiredTypeDefaultDescription
countTruenumber3The value has to be an integer greater than or equal to 1. If an exception occurs, it will automatically return to the try block to retry. If there are still exceptions after the retry, the statement in the catch block will be executed

Demo

TracePrint("------------------------------------Exception Retry------- -----------------------------------") 
//[Remarks] Use try catch to handle code blocks that may cause exceptions.
//-------------------------------------------------------------------------------
TracePrint "Retry to execute the content in try three times, if an exception occurs, execute the content in Catch"
Try 3
TracePrint "a"
TracePrint []&"a"
Catch e
TracePrint error
Else
TracePrint "123"
End Try