Fixed weird erroring with an error handling

This commit is contained in:
Yoshman29
2022-12-26 22:17:08 +01:00
parent 11db805c34
commit 4ca6e2a680
+24 -15
View File
@@ -335,20 +335,31 @@ class Interp {
function exprReturn(e):Dynamic {
try {
return expr(e);
} catch (e:Stop) {
switch (e) {
case SBreak:
throw "Invalid break";
case SContinue:
throw "Invalid continue";
case SReturn:
var v = returnValue;
returnValue = null;
return v;
try {
return expr(e);
} catch (e:Stop) {
switch (e) {
case SBreak:
throw "Invalid break";
case SContinue:
throw "Invalid continue";
case SReturn:
var v = returnValue;
returnValue = null;
return v;
}
} catch(e) {
error(ECustom('${e.toString()}'));
return null;
}
} catch(e:Error) {
if (errorHandler != null)
errorHandler(e);
else
throw e;
return null;
} catch(e) {
error(ECustom('${e.toString()}'));
trace(e);
}
return null;
}
@@ -374,9 +385,7 @@ class Interp {
inline function error(e:#if hscriptPos ErrorDef #else Error #end, rethrow = false):Dynamic {
#if hscriptPos var e = new Error(e, curExpr.pmin, curExpr.pmax, curExpr.origin, curExpr.line); #end
if (errorHandler != null)
errorHandler(e);
else if (rethrow) {
if (rethrow) {
this.rethrow(e);
} else {
throw e;