C.81 ThrowTask
Prev | Appendix C. Optional tasks | Next

## C.81 ThrowTask

Extension of build in `FailTask` that can throw an exception that is given by a reference. This may be useful if you want to rethrow the exception that has been caught by a `TryCatchTask` in the <catch> block.

Table C.111: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`refid` | `String` | Id of the referenced exception. | n/a | No

### Note

In addition, all attributes of the `FailTask` are supported.

### C.81.1 Example

    <target name="tryCatchThrow">
      <trycatch property="foo" reference="bar">
        <try>
          <fail>Tada!</fail>
        </try>

        <catch>
          <echo>In <catch>.</echo>
        </catch>

        <finally>
          <echo>In <finally>.</echo>
        </finally>
      </trycatch>

      <echo>As property: ${foo}</echo>
      <property name="baz" refid="bar" />
      <echo>From reference: ${baz}</echo>

      <echo>Throw ...</echo>
      <throw refid="bar" />

    </target>

Prev | Up | Next
C.80 TarTask | Home | C.82 UntarTask