From Xojo Documentation

Revision as of 22:57, 28 August 2019 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from RuntimeException)

Occurs when the calling chain becomes too long.

ErrorNumber Message
Stack StackFrames


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.

Sample Code

The following method calls itself until the stack overflows:

Function Square (value As Integer) As Integer
Return Square(value)
End Function

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

Function Square (value As Integer) As Integer
Return Square(value)

Exception err
If err IsA StackOverflowException Then
MessageBox("The stack has overflowed!")
End If

See Also

RuntimeException class; Function, Raise, Sub statements, Nil datatype; Exception, Try statements.