System.GetLastErrorCallStack() Method

Version: Available or changed with runtime version 1.0.

Gets the call stack from where the last error occurred.


String :=   System.GetLastErrorCallStack()


This method can be invoked using property access syntax.


This method can be invoked without specifying the data type name.

Return Value

‚ÄÉType: Text


For some errors, such as divide by zero errors and overflow errors, GetLastErrorCallStack does not return every call in the stack. To get the complete call stack for these types of errors, use the debugger and specify that you want to break on errors. On the Debugger page, in the Call Stack FactBox, you can view all the method calls that led to the error.


In this example, an error occurs in codeunit 50003. The text of the Message includes a call to the GetLastErrorCallStack method.

// Codeunit 50001, TestErrors1  
// OnRun trigger  
Error('Some error message')  
// Codeunit 50002, TestErrors2  
// OnRun trigger  
if not Codeunit.Run(50001) then  
  Message('The call stack for the last error is:\' + GetLastErrorCallStack);  

When you run codeunit 50002, the message window displays the following:

The call stack for the last error is:

TestErrors1(CodeUnit 50001).OnRun(Trigger) line 1

TestErrors2(CodeUnit 50002).OnRun(Trigger) line 2

See Also

System Data Type
Get Started with AL
Developing Extensions