throw
Description
Intentionally throw an error. When you throw an error, the normal flow of code execution stops, and control is passed to the nearest catch block, while passing the error message.
Input / Parameter
value
The error message to throw.
Text/String
-
-
No
Output
N/A
Callback
N/A
Example
In this example, we will do console logging by using console and throw function in tryCatch function callback to demonstrate how throw works.
Code Equivalent
try {
throw new Error("There is an error");
} 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
throwto thetryCatchfunction try callback, on it'svalueparam adderror from throwas 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
error from throwandfinallyon the console.
Links
Related Information
See also:
Last updated