The CLI implements a simplified analogue of Java's try-catch-finally control flow. It consists of three sets of operations and commands (with each set being a batch) corresponding to the try, catch and finally blocks. Both catch and finally blocks are optional but at least one of them should be present. Unlike in Java, only one catch block can be specified.
The control flow begins with execution of the try batch. If the try batch finished successfully (i.e. the outcome of the operation was success), then the catch batch is skipped and the finally batch is executed. If the try batch failed (i.e. the outcome of the operation was failure, in case of, e.g., a java.io.IOException the whole try-catch-finally control flow will terminate immediately) then the catch batch (if it is present) will be executed. The finally batch (if it is present) will always execute at the end of the control flow no matter whether the try and catch batches succeeded or failed to execute.
There are four commands that define the try-catch-finally control flow: try, catch, finally and end-try.
try command starts the try batch. The try batch continues until one of catch or finally command is met.
catch command marks the end of the try batch (the try batch is then held back) and starts the catch batch.
finally command marks the end of the catch batch (if the current batch is a catch batch) or the try batch (if the catch batch was not specified) and starts the finally batch.
end-try is the command that ends either catch or finally batch (depending on which one was the last one) and runs the try-catch-finally control flow.
Here is an example that either creates or re-creates a datasource and enables it: