arc:catch

Version 23.4.8839


arc:catch

Version 23.4.8839


The arc:catch keyword is used to create an exception-handling block in a script. In addition to arc:try, you can contain an arc:catch block within any of the following keywords, the scope of which serves as an implicit arc:try section:

Parameters

  • code: The code parameter allows you to selectively catch exceptions. To catch all exceptions, use the character *.

Control Attributes

  • _code: The code of the caught exception.
  • _description: A short description of the caught exception.
  • _details: More information about the exception, if available.

Examples

Wrap a more user-friendly message around the error output from a batch file or shell command:

<arc:try>
<arc:call op="sysExecute">
  <arc:check attr="sys:error">
    <arc:throw code="myerror" description="Batch file could not be executed" details="[sys:error]"/>
  </arc:check>
</arc:call>
<arc:catch code="*">
  <arc:call op="appSendEmail"/>
</arc:catch>
</arc:try>

Throw and catch an exception. Inside an arc:call, an RSBException is thrown and caught. Inside the scope of the keyword, the arc:ecode and arc:emessage attributes are added to the current item and pushed out.

<arc:call op="...">
  <arc:throw code="myerror" description="thedescription" details="Other Details."/>
  <arc:catch code="myerror">
    <arc:set attr="arc:ecode" value="[_code]"/>
    <arc:set attr="arc:emessage" value="[_description]: [_details]"/>
    <arc:push/>
  </arc:catch>
</arc:call>

Catch all exceptions:

<arc:catch code="*">
  An exception occurred. Code: [_code], Message: [_description]
</arc:catch>

See Also