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
Steps
Drag a
button
component into the canvas and open theAction
tab. Select thepress
event of the button and drag thetryCatch
function to the event flow.Drag the function
console
to thetryCatch
function try callback, on it'svalue
param addtry
as value.Drag the function
console
to thetryCatch
function catch callback, on it'svalue
param change the param type toinput
.Drag the function
console
to thetryCatch
function catch callback, on it'svalue
param addfinally
as value.
Result
Now click the button in preview, it will only show
try
andfinally
on the console.
Links
Related Information
See also:
Functions
Last updated