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
-1
View File
@@ -3,7 +3,6 @@ function create() {
pixelNotesForBF = false;
enablePixelUI = true;
enableCameraHacks = false;
// defaultCamZoom = 0.5;
}
function updatePost(elapsed) {
+1 -1
View File
@@ -1 +1 @@
1261
1265
+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) {
+1 -1
View File
@@ -205,7 +205,7 @@ class Script extends FlxBasic implements IFlxDestroyable {
*/
public function error(text:String, ?additionalInfo:Dynamic):Void {
Logs.traceColored([
Logs.logText(fileName, GREEN),
Logs.logText(fileName, RED),
Logs.logText(text)
], ERROR);
}
+1 -2
View File
@@ -88,9 +88,8 @@ class MusicBeatState extends FlxUIState implements IBeatReceiver
stateScript = Script.create(Paths.script('data/states/${scriptName}'));
stateScript.setParent(this);
stateScript.load();
} else {
} else
stateScript.reload();
}
}
}
override function create()