Gentee Programming Language > Documentation > Syntax Download documentation

Exception throwing - throw

The throw function (command) throws an exception. An exception code is required to be specified in the first argument, the type of the second argument must coincide with the type of the second argument in the appropriate handler-function. An exception codes that are less than 256 are reserved.

<throw> ::= throw '(' <expression> ',' <expression> ')'

func uint myexcept( uint code, uint param )
{
if code == $MYEXCEPT
{
print( param->str )
return 1
}
elif code == $MYUINTEXCEPT
{
print( "Exception: i = \( param )\n")
return 1
}
return 0
}

func a
{
...
if i < 10 : throw( $MYEXCEPT, "The i value cannot be less than 10" )
...
if i > 100 : throw( $MYUINTEXCEPT, i )
}

See also

    Exception handlers - exception    Termination handling - finally


 Copyright © 2004-2006 Gentee Inc. All rights reserved.