better hscript error handler

This commit is contained in:
Yoshman29
2022-11-10 16:23:41 +01:00
parent 38d2a767aa
commit eb780cda6d
5 changed files with 15 additions and 7 deletions
+12 -2
View File
@@ -23,13 +23,23 @@ class HScript extends Script {
interp.variables.set("trace", this.trace);
try {
expr = parser.parseString(code, fileName);
} catch(e:Error) {
_errorHandler(e);
} catch(e) {
return;
_errorHandler(new Error(ECustom(e.toString()), 0, 0, fileName, 0));
}
}
private function _errorHandler(error:Error) {
this.error('$fileName:${error.line}: ${error.toString()}');
var fn = '$fileName:${error.line}: ';
var err = error.toString();
if (err.startsWith(fn)) err = err.substr(fn.length);
Logs.traceColored([
Logs.logText(fn, GREEN),
Logs.logText(err, RED)
], ERROR);
}
public override function setParent(parent:Dynamic) {