<try>
Purpose/Function
Tasks are normally implemented to catch all exceptions and rethrow them as ScriptExecutionExceptions
. If a particular task (sequence) should not cause this exception to be propagated to the caller of the script, then <try>
should be used to wrap it.
The caught exception can be handled in a number of different ways. If errorProperty is set, a global variable with that name will be declared with a value of "true"; there is also an option to go ahead and rethrow the exception after handling.
Special handlers should be added to the try task as <exception-handler>
elements. These should either first be declared in scope, then passed in as a reference to the handler element TEXT
, or added using the absoluteTag namespace. As always (see 5. Interchanging Attributes and Tags), a singleton handler could also be passed in as an exceptionHandler attribute.
Error handlers should implement the ncsa.tools.ogrescript.ITaskExceptionHandler
interface; currently only one implementation is provided by OgreScript core: the logging handler (see below).
See also <throw>
.
Attributes
NAME |
TYPE |
DEFAULT VALUE |
DESCRIPTION |
---|---|---|---|
errorProperty |
|
|
assign |
rethrow |
|
|
rethrow the exception after handling |
Special Elements
TAG |
TYPE |
COUNT |
DESCRIPTION |
---|---|---|---|
|
|
0:N |
deals with the exception in some way |
Example
<declare name="errorMessage" string="could not complete phase 1"/> <try errorProperty="phase1error"> <exception-handler.logging-exception-handler errorMessage="${errorMessage}" includeTrace="true"/> <do-something/> <do-something-else/> <clean-up/> </try>
ncsa.tools.ogrescript.types.LoggingExceptionHandler
<logging-exception-handler>
Purpose/Function
Logs the caught exception.
Attributes
NAME |
TYPE |
DEFAULT VALUE |
DESCRIPTION |
---|---|---|---|
errorMessage |
|
|
special message to include with exception logged |
includeTrace |
|
|
include full stack trace |
Elements
None.
ReturnValues
None.
See above for example.