I am running on C# - lua project. The project has all logic in lua part, and c# part holds the built-in console to display result and take input. So debugging is almost occurred in lua part. My lua codes looks like below:
[lua]
#region main
1 foo(blah)
2 bar(blah) -- bad argument, will provoke error
#end
#region functionsholder
1 function foo(argument)
2 --do something
3 end
4 function bar(argument)
5 --do something with argument.
6 end
#end
then in my project, c# holds two string chunks, namely main and functionsholder. Then my c# code runs as below:
[c#]
1 public void runscript(string name)
2 try
3 {
4 lua.Dostring(name);
5 }
6 catch (LuaException e)
7 {
8 Console.Writeline("An unhandled exception occured at string chunk " + name + ".");
9 Console.WriteLine(e);
10 }
11 runscript("functionsholder"); // need to load functions first.
12 runscript("main"); // start main code block, and by above, this result in exception.
The problem(which I think) is the log message.
An unhandled exception occured at string chunk main.
LuaInterface.LuaException: [string "chunk"]:5: bad argument #1 to 'pairs' (table expected, got nil)
위치: LuaInterface.Lua.ThrowExceptionFromError(Int32 oldTop)
위치: LuaInterface.Lua.DoString(String chunk)
위치: SomeProject.SomeClass.runscript(String name) 파일 d:\Git\SomeSolution\SomeProject\SomeClass.cs:줄 4
To debug this code, i think it is important to know where the code fails. However I cannot get proper information because LuaException only give the information of line number, and not chunk name. My error handling code gives a chunk name, but it is useless because exception is thrown in other chunk.
Thank you for your patience to read this so far and my question is here(and obvious): How can I get proper error message to look into? I want two information, which are 1) line number of exception thrown. 2) string chunk name to which the exact line belongs.