/*
 * Test exceptions
 */

class WrongTypeException : exception
{
    method WrongTypeException()           { Error = 1; }
    method WrongTypeException(int error)  { Error = error; }
    method int getError()                 { return Error; }
    int Error;
}

function string main(const string[] args)
{
    int[] values   = { 10, 20, 30 };
    string[] names = { "Judy", "Christopher", "Helen", "James", "Sandra", "Rick", "Elisabeth", "Johnboy" };

    // increment all array elements by 1
    values = values.process( Incrementor, null );
    names  = names.process ( Incrementor, null ); // this will throw in Incrementor()

    return new string("We will never get here");
}

function var Incrementor(const var element, var args)
{
    if( typeof(element) != typeof(int) )
        throw new WrongTypeException();

    return element + 1;
}