Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

This task is to give an example of an exception handling routine
and to "throw" a new exception.



Related task

   Exceptions Through Nested Calls


import Exceptions
 
procedure main(A)
    every i := !A do {
        case Try().call{ write(g(i)) } of {
            Try().catch(): {
                x := Try().getException()
                write(x.getMessage(), ":\n", x.getLocation())
                }
            }
        }
end
 
procedure g(i)
    if numeric(i) = 3 then Exception().throw("bad value of "||i)
    return i
end