Update error handling inside extlibs

This commit is contained in:
2026-01-18 21:37:46 +11:00
parent 72162a7410
commit 754b63fb75
5 changed files with 42 additions and 112 deletions

View File

@@ -90,7 +90,7 @@ bool isMainScopeGlobal = true;
printGroundInstruction(error->where);
printf("\n");
}
if (error->line > -1) {
if (error->hasLine) {
printf(" ErrorLine: %zu\n", error->line + 1);
}
exit(1);
@@ -1762,6 +1762,9 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
if (function->nativeFn) {
GroundValue returnValue = function->nativeFn(scope, argsList);
if (returnValue.type == ERROR) {
returnValue.data.errorVal.line = currentInstruction;
returnValue.data.errorVal.hasLine = true;
returnValue.data.errorVal.where = in;
if (scope->isMainScope) {
throwError(&returnValue.data.errorVal);
}