Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

Change default reported number to something invalid (-1) to make it clear when it's wrong. #217

Open Dunbaratu opened 10 years ago

Dunbaratu commented 10 years ago

There seems to be a lot of difficulty in getting the line number reporting for errors correct. Expression Errors, Flagrant Errors, and Syntax Errors all seem to have a tendency to report the bogus line number zero when it's not really on line zero.

How about this as an idea: Until this is completely fixed, for now default the reported line number variable to an obviously invalid number, like negative 1 for example. That way in the cases where the line number isn't being updated or set right, it's obvious to the user that it's not giving them the right number and they have to search for the real number.

Right now, the user can't tell the difference between these two cases:

"This is telling me I have an error on line 0 because I really do have an error on line 0 which is the first line of the script."

"This is telling me I have an error on line 0 because it failed to calculate the line number and 0 is just the default value it always reports."

Seeing a message line "Syntax Error on line -1" would make it crystal clear it's really the second case.

JoCRaM commented 10 years ago

it depends on how far you've got in parsing , but if you can output - say -10 characters before the start of the block, the first ten characters of the blook, ..., the last ten characters of the block and then the first 10 after the block that might help the user find the problem.