Skip to content

CallStackDump Command

See Also

Purpose

Retrieves the same message stack information you would see in your error dialog and places it in a string.

Syntax

CallStackDump {StringVariable}

Where {StringVariable} is a variable of type String.

What It Does

When an error is generated, the [Error_Report](../VdfClassRef/ErrorSystem-Event-Error_Report.md) event gets called, which may be used to customize error reporting. When customizing unhandled error reporting, a special command, CallStackDump, is provided that allows you to retrieve the message stack information.

The CallStackDump command retrieves the same message stack information you would see in the error dialog and places it in a string. You can use this to perform other actions with the error information, such as logging it to a file or sending an error report. The CallStackDump command should only be used within the error handler's Error_Report event.

Example

The following example creates a replacement error handler that logs all unhandled errors. Because this is an example, the logging will simply display the error in the Showln dialog.

Object oError is a ErrorSystem
    Property Boolean pbInError False

    Procedure Error_Report Integer iError Integer iLine String sErrMsg
        String sStack
        Boolean bUnhandled bBusy

        // Augment to log unhandled errors
        Get pbInError to bBusy
        If not bBusy Begin
            Set pbInError to True
            Get IsUnhandledError iError to bUnhandled
            If bUnhandled Begin
                CallStackDump sStack
                Send LogUnhandledError iError iLine sErrMsg sStack
            End
            Set pbInError to False
        End

        // Now do the normal error report.
        Forward Send Error_Report iError iLine sErrMsg
    End_Procedure

    Procedure LogUnhandledError Integer iError Integer iLine String sErrMsg String sStack
        Showln "Unhandled Error: " iError " at " iLine
        Showln sErrMsg
        Showln sStack
        Showln
    End_Procedure

    // Note: this line is only needed if using this error handler
    // in objects or classes not derived from ErrorSystem
    Move Self to Error_Object_Id
End_Object