StackOverFlowException

From Xojo Documentation

Revision as of 19:13, 19 November 2009 by Npalardy (talk | contribs) (1 revision)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


Description

Occurs when the calling chain becomes too long.


Super Class

RuntimeException

Notes

Not surprisingly, a StackOverflowException occurs when the stack overflows. This happens when the calling chain gets too long. This can easily happen when your code makes a recursive call without providing a way to terminate the recursion-or the condition that terminates the recursive call takes too many calls to occur.


Examples

The following method calls itself until the stack overflows:

Function Square (value as Integer) as Integer
Return Square(value)

You can handle the function with the following simple Exception handler:

Function Square (value as Integer) as Integer
Return Square(value)
If err IsA StackOverflowException then
MsgBox "The stack has overflowed!"
 end if


See Also

RuntimeException class; Function, RaiseSub statements, Nil datatype; Exception, Try statements.