Skip to content

Control: Try () catch () finally ()

Jaume Olivé Petrus edited this page Oct 29, 2017 · 9 revisions

This block is a Control block that execute a script that can potentially trigger an exception (try part), handle the exceptions without stop the program (catch part), and continue with the normal execution of the program regardless of whether an exception has occurred (finally part).

The exceptions are handled in the catch part using the "When error () is catched do ()" which can execute a script or another depending on the exception.

Shape

Example

In this example a transmission to the LoRa network is protected by a try block. The transmission fails because a network connection is not stablished.

Run this example in The Whitecat IDE.

Clone this wiki locally