bug
bug copied to clipboard
ScriptException.getLineNumber returns an inaccurate value
Scala version: 2.12.6 Java version: 8
I have a series of scripts that are evaluated with the Scala ScriptEngine like so
for (Script script : plugin.getScripts()) {
try {
engine.eval(script.getContents());
} catch (ScriptException e) {
throw new ScriptInterpretException(script, e);
}
...
}
When an exception is thrown, the line number that it returns is inaccurate. For example, take this script
import io.luna.game.event.impl.ServerLaunchEvent
import io.luna.game.model.mob.Player
private val TICK_INTERVAL = 1500 // 15 mins
private val MESSAGES = Vector(
"Luna is a Runescape private server for the #317 protocol.",
"Luna can be found on GitHub under luna-rs/luna",
"Change these messages in /plugins/world/announcements/announcements.scala",
"Any bugs found using Luna should be reported to the GitHub page."
)
private val FILTER = (plr: Player) => plr.rights <= RIGHTS_ADMIN
on[ServerLaunchEvent] { msg =>
world.scheduleForever(TICK_INTERVAL, error here!!!) { // error, line 21
world.players.
filter(FILTER).
foreach { _.sendMessage(pick(MESSAGES)) }
}
}
getLineNumber should return 21 but instead it returns 221. In this instance, you could subtract 200 to get the line number but normally the value is unpredictable (ranges between 150-300). Could this be because the line number counter isn't being reset after each script evaluation? If so, is this the intended behavior?