Example: StackTrace property

Using three Java Classes, this script demonstrates an error that would cause a stack trace. The result is printed under the section labeled "LotusScript® code."

In ClassA.java

public class ClassA {
	ClassB CB = new ClassB();

	public int FunctA(){
		return CB.FunctB();
	}
}

In ClassB.java

public class ClassB {
	ClassC CC = new ClassC();

	public int FunctB(){
		return CC.FunctC();
	}
}

In ClassC.java

public class ClassC {
	int x = 10;
	int y = 0;

	public int FunctC(){
		return x/y;
	}
}
   

LotusScript® code

Dim mySession As JavaSession
Dim myClass As JavaClass
Dim myMethod As JavaMethod
Dim myObject As JavaObject
Dim myError As JavaError

Set mySession = New JavaSession ()

Set myClass = mySession.GetClass("ClassA")
Set myObject = myClass.CreateObject("()V")

Set myMethod = myClass.getMethod("FunctA", "()I")

On Error GoTo errhandler:
print myMethod.invoke(o)
	
done:
exit sub

errhandler:
set myError = mySession.getLastJavaError()

MessageBox myError.StackTrace,, Error
Resume done
	
(Results)
java.lang.ArithmeticException: / by zero

	at valid5.javaconn.java.ClassC.FunctC(ClassC.java:6)

	at valid5.javaconn.java.ClassB.FunctB(ClassB.java:5)

	at valid5.javaconn.java.ClassA.FunctA(ClassA.java:5)