swirl
Guide to OmniMark 9   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax   Related Concepts  
control structure  

rethrow

 
 

Syntax

rethrow


Purpose

You can use rethrow to resume a caught throw. You can only use rethrow within a catch block. The new instance of the throw is created regardless of any other throws pending, and is dealt with in the same manner as any other throw.

The new throw has the same name and all the parameters of the original throw, even if you did not list all the parameters in the rethrowing catch.

The following is an example of rethrow used with #program-error.

  global integer my-first-counter initial {5}
  global integer my-second-counter initial {0}
  
  define integer function divide value integer numerator by value integer denominator as
     return numerator / denominator
     catch #program-error code error-code
       rethrow unless error-code = 1219 
       return 0
  
  process
    do
      output "%d(my-first-counter) divided by %d(my-second-counter) is: " 
        || "d" % divide my-first-counter by my-second-counter
        || "%n"
    done

The first catch of #program-error deals only with an attempt to divide by zero. Use rethrow so that all other causes of a #program-error are rethrown and dealt with appropriately by other catch statements.

If a rethrow is not caught, the program will terminate.

    Related Syntax
 
Related Concepts
 
 

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ LEGACY LIBRARIES ] [ ERRORS ]

OmniMark 9.1.0 Documentation Generated: September 2, 2010 at 1:51:21 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2010.