SF_Exception to return source name

Good Morning,
As per the documentation in the link ScriptForge.Exception service (SF_Exception)

The properties show:

Name Readonly Description
Description No The error message text. Default value is “” or a string containing the Basic run-time error message.
Number No The code of the error. It can be a numeric value or text.Default value is 0 or the numeric value corresponding to the Basic run-time error code.
Source No The location in the code where the error occurred. It can be a numeric value or text. Default value is 0 or the code line number for a standard Basic run-time error.

Using a modification of the sample code from the same link I made the following code:

Sub Main
Dim a, b, c
	GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
	SF_Exception.Clear()
    On Local Error GoTo Catch
    Try:
    	doit()
        Exit Sub
    Catch:
        with SF_Exception
    		.DebugPrint(.Number,.Description,.Source)
    		.console(Modal := False)
    		.Clear()
    	end with
End Sub

sub doit()
Dim a, b, c
	a = 10 : b = 0
	c = a / b
end sub

The result from the console is
08:29:37 -> 11 Division by zero. 9

As you can see SF_Exception.Source returns the line number, which 9. So how could I get the sub or function name which causes the error?

would need to have access to the callstack, which Basic does not support (yet).
154595 – On Local Error help is misleading

1 Like

Thank you very much.