URL:
<http://gna.org/patch/?1526>
Summary: Print code listing on errors in lua script (when
possible)
Project: Freeciv
Submitted by: englabenny
Submitted on: lördag 2010-03-13 den 20:32
Category: None
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Planned Release:
_______________________________________________________
Details:
When we have the script code string available, use it on error in
script_call so we can show the lines where the error was encountered.
If there is a lua error in script_callback_invoke, when we call an
event callback, we assume the callback is defined in the section
script.code. If we always use the source code from script.code here,
we get the exact lines of the code where the error was encountered in
the error message.
This change will have strange effects if the user defines callbacks
inside script.vars, because we will print the correct error message
for the error, but try to display code from the corresponding line
numbers in script.code. However this should never happen.
With this change, the user/developer can see the lines of code
surrounding the error immediately, and often gets an arrow pointing
exactly at the line containing the error.
---
The effect is very nice for the user/developer:
1: lua error:
[string "script.code"]:47: attempt to call field 'stuff' (a nil
value)
stack traceback:
[string "script.code"]:47: in function <[string "script.code"]:46>
44: end
45:
46: function turn_callback(turn, year)
--> 47: signal.stuff()
48: end
49:
50: signal.connect("turn_started", "turn_callback")
Now we are talking error messages! Quite a step up, all taken together, from
the "error in error reporting" we had before.
I hope this can go into 2.2 and trunk.
See also
https://gna.org/bugs/?15531
https://gna.org/bugs/?15602
https://gna.org/bugs/index.php?15606
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1526>
_______________________________________________
Meddelandet skickades via/av Gna!
http://gna.org/
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev