Skip to main content

Throw-Exception

Command Description

Throw a custom error, the current program will stop running (the statement after “Throw” won't be executed), the thrown error can be captured with try-catch

Command Prototype

Throw message

Parameter Description

ParameterRequiredTypeDefaultDescription
messageTruestring""Throw content

Demo

TracePrint("------------------------------------Throw exception-------- -----------------------------------") 
//[Remarks] If a custom exception is thrown, the running of the current program will be stopped (the statement after Throw will not be executed), and the custom exception thrown can be caught using the Exception Catch (Catch) command.
//-------------------------------------------------------------------------------
TracePrint "UB is that you cannot use an array to concatenate strings, and a custom exception is thrown"
Try
TracePrint []&"a"
Catch error
TracePrint error
Throw "Syntax error"
End Try