Docs Menu
User Guide / Control Structures / TCF

Try Catch and Finally (TCF) Block

The exception is defined as an unanticipated condition that can occur while the execution of code. It interrupts the flow of code that can lead to abnormal termination of the program which can affect data, results, or even the environment. Exception handling is a very important feature of any programming language. It enables a programming language to handle these unanticipated conditions leading to a proper termination of the program saving data, results, and the environment.

In Syncloop this exception handling is carried out using TRY, CATCH, and FINALLY blocks. There can be two situations of carrying out TCF Blocks

A) Control flow in try-catch clause OR try-catch-finally clause

Case 1: Exception occurs in a TRY block and is handled in the CATCH block

Case 2: Exception occurs in the TRY block is not handled in the CATCH block

Case 3: Exception doesn’t occur in TRY-block

B) try-finally clause

Case 1: Exception occurs in the TRY block

Case 2: Exception doesn’t occur in try-block

These blocks come in pairs. to create a TRY, CATCH, and FINALY Block on Syncloop. Right-Click on the Workspace and select TCF block.

Root Properties

Once the TCF-Block is selected a TCF-Block is created in the workspace

Root Properties

TCF Properties

It has three main properties

Status: To enable/disable the TCF Block. The default status will be in enabled mode. If the status is selected as disabled in the case switch & its child cases and further steps will not execute when the API service will be invoked either from HTTP or from another service.
Snapshot: Create a runtime data state snapshot for the switch step.
Comment: Add comment to the TCF Block.

Enable Condition for the Evaluation of Sub Steps:

TRY Block

The TRY statement defines a code block that tests for runtime errors while it is being executed. Once a TRY Block is created, we can add Group, Switch, a new TCF Block, ForEach, Redo, Transformer, and Service. All the runtime errors are raised in the TRY Block.

To disable the TRY block right-click on the block and select properties. Select the drop-down box for status and set it to disabled. The whole block will be disabled and the disabled caption will be visible on the block.

CATCH Block

The CATCH statement defines a code block that gets executed once any specified runtime error takes place in the try block. Once a CATCH Block is created, we can add Group, Switch, a new TCF Block, ForEach, Redo, Transformer, and Service. All the runtime errors will get caught in the CATCH Block once they are handled properly.

To disable the CATCH block right-click on the block and select properties. Select the drop-down box for status and set it to disabled. The whole block will be disabled and the disabled caption will be visible on the block.

FINALLY, Block

The FINALLY block is executed every time regardless of the result in TRY or CATCH block. Once a FINALLY Block is created, we can add Group, Switch, a new TCF Block, ForEach, Redo, Transformer, and Service.

To disable the FINALLY block right-click on the block and select properties. Select the drop-down box for status and set it to disabled. The whole block will be disabled and the disabled caption will be visible on the block.