Skip to content

Traceback.ToString(n) trims off more than expected #170

Open
@CodeSmile-0000011110110111

Description

Using 0.5 (built the DLLs sometime this week).

I am logging this from a Lua script that was run by dofile("AuxEditorScript.lua") from MainEditorScript. The default log is this:

Hello, AuxEditorScript! Script table: table: 1568106766
stack traceback:
	[C#]: in function 'LogInfo'
	New Folder/AuxEditorScript.lua:2: in main chunk
	[string "MainEditorScript"]:11: in main chunk

I used a helper method to try and strip the topmost trace as I don't want the logging function itself be in the stack traceback:

private static String GetLuaMessageAndTraceback(LuaFunctionExecutionContext context)
{
	var traceback = new Traceback(context.State, context.Thread.GetCallStackFrames());
	return $"{context.ArgumentsToString()}\n{traceback.ToString(1)}";
}

But the ToString(1) actually trims the topmost two entries. I suspect this has something to do with the topmost being a C# method:

Hello, AuxEditorScript! Script table: table: -1870934124
stack traceback:
	[string "MainEditorScript"]:11: in main chunk

I would expect that just the "LogInfo" line disappears.

GetTracebackString has this parameter bool skipFirstCsharpCall = false but it is unused and inaccessible because the method is internal. That sounds about what I need, unless "first" is meant as the entry point, not the logging method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions