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


 
// Create a new error class by subclassing sys::Err
const class SpecialErr : Err 
{
  // you must provide some message about the error 
  // to the parent class, for reporting
  new make () : super ("special error") {}
}
 
class Main
{
  static Void fn ()
  {
    throw SpecialErr ()
  }
 
  public static Void main ()
  {
    try
      fn()
    catch (SpecialErr e)
      echo ("Caught " + e)
  }
}
 