swirl
Guide to OmniMark 8   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
   #program-error
   #external-exception
   always
   throw
   catch
 
Related Concepts
   Catch and throw
 
 

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

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:33:48 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.