tryCatch
Description
Handling exceptions (errors) in code execution. It allows you to "try" a block of code, "catch" any errors that occur, and optionally "finally" execute some code regardless of whether an error was thrown or not
Input / Parameter
N/A
Output
N/A
Callback
try callback
The functions to be executed.
catch callback
The functions to be executed when there is an exception.
Returns an error.
Error
finally callback
The functions to be executed regardless of the exception is thrown or caught.
Example
In this example, we will do console logging by using console function in tryCatch function callback to demonstrate how tryCatch works.
Code Equivalent
try {
console.log("try")
} catch (e) {
console.log(e)
} finally {
console.log("finally");
}Steps
Drag a
buttoncomponent into the canvas and open theActiontab. Select thepressevent of the button and drag thetryCatchfunction to the event flow.
Drag the function
consoleto thetryCatchfunction try callback, on it'svalueparam addtryas value.
Drag the function
consoleto thetryCatchfunction catch callback, on it'svalueparam change the param type toinput.
Drag the function
consoleto thetryCatchfunction catch callback, on it'svalueparam addfinallyas value.
Result
Now click the button in preview, it will only show
tryandfinallyon the console.
Links
Related Information
See also:
Functions
Last updated