TRY – CATCH End Flow


The try-catch construct is a block that allows you to capture the exceptions that can be generated by the various blocks of Deepser flows.

It consists of two blocks respectively the Try block and the catch block.

In the right branch of the try block you will have to insert the blocks of which we want to capture any exceptions, in the left branch a Catch block will be placed, which in turn will perform the actions placed in its right branch if and only if an exception will be generated in the try block.

Example of configuration of the “TRY – CATCH” block

Suppose you want to run a script that might throw an exception during its execution, and you want to log in a custom error message if an exception is raised.

To do this we are going to insert a try block in whose right branch we are going to insert a “Script” block, in which we are going to insert the following code:

$operationCollection = Deep::getResourceModel('deep_service/operation');

$operationMap = $operationCollection->toOptionHash();

//.... rest of the code

Note: In our example we are going to deliberately insert a block of code that contains an errorn so that we can test the TRY-CATCH construct in particular the alias to get the Operation collection is “deep_service/operation_collection” and not “deep_service/operation”, which is the alias to retrieve a single operation.

Then the script block will be configured like this:

In the left branch of the try block we are going to insert a “Catch” block which in turn will have a desta branch in which we are going to insert our custom logging function.

In particular, in the right branch of the catch block we are going to insert a “Log” block configured as follows:

Below the “Log” block We will have to go and insert an “End Flow” block, in the specific case it can be avoided since there are no other actions to be performed, but in a more general case it may be sensible to exit the flow in case an exception occurs.

At this point the result will look like this: