Gentee Programming Language > Documentation > Syntax Download documentation

Termination handling - finally

In some cases if the exception occurs, additional operations must be performed. For example: to close files, to free the memory, etc. The finally command is used to perform these operations. The command can be used on the first level of block nesting inside the function. The code below this command will be executed even if the exception occurs. In this case, you are able to return the required value.

func a
{
...
if i < 10 : throw( $MYEXCEPT, "The i value cannot be less than 10" )
...
finally
print("A: This message will be displayed in any case\n")
}

func uint b
{
uint ret
exception( &myexcept )
...
a()
print("This message cannot be shown if there is an exception in a()\n")
ret = 1
finally
print("B: This message will be displayed in any case\n")
return ret
}

<finally> :: = finally

See also

    Exception handlers - exception    Exception throwing - throw


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