The XML schemas provides a set of elements for handling possible errors . The parent of this set of elements is the <try> element. You might use these elements for situations similar to the following examples:
To suppress errors during deployment. For example, if installation of a component consists of deploying some files or other resources followed by a restart and the restart fails, then the installation itself does not fail.
To control whether a step that depends on another step should be performed. For example, if you need to perform both useradd and groupadd functions, the groupadd should only be performed if the useradd is successful.
To determine which install path to take. For example, if you are installing version 1.1 of an application, the install path might be different depending on whether version 1.0 of that application is on the target host.
The <try> element includes a block of steps that are executed in order until either all complete successfully or a step fails. If a step fails and a <catch> element exists, then the steps in the <catch> element are executed in order until they succeed or a step fails. If a <finally> element is defined, the steps in the <finally> element are executed in order until all steps complete or a step fails regardless of whether the <try> and <catch> elements succeeded. Typically, the <finally> element is used to perform clean-up functions or release resources.
The <raise> element is used to indicate a failure condition without having to create a step to do so. The <raise> step always fails. Although the <raise> element can be used by itself, it is often contained within a <catch> element block.
The following XML example uses the <try> element to determine whether a fresh install or an upgrade install should be performed.
<installSteps blockName="default"> <try> <block> <checkDependency> <installedComponent name="foo" version="1.0" /> </checkDependency> </block> <catch> </catch> </try> </installSteps>