diff --git a/SMILEBASIC/VM.d b/SMILEBASIC/VM.d index 0381cb3..3b0ee1c 100644 --- a/SMILEBASIC/VM.d +++ b/SMILEBASIC/VM.d @@ -1560,7 +1560,15 @@ class CallBuiltinFunction : Code arg = vm.stack[vm.stacki - argcount..vm.stacki]; result = vm.stack[vm.stacki/* - argcount */+ 1..vm.stacki + 1/* - argcount */+ outcount];//雑; } - func.func(vm.petitcomputer, arg, result); + try + { + func.func(vm.petitcomputer, arg, result); + } + catch (SmileBasicError sbe) + { + sbe.func = func.name; + throw sbe; + } if(func.variadic) { vm.stacki -= argcount; diff --git a/SMILEBASIC/error.d b/SMILEBASIC/error.d index e2f6b91..872949f 100644 --- a/SMILEBASIC/error.d +++ b/SMILEBASIC/error.d @@ -10,6 +10,7 @@ class SmileBasicError : Exception int errline; int errprg; string message2; + string func; this(int slot, int line, string message) { super(format("%s in %d:%d", message, slot, line)); diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index bb22290..aca3e8f 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -1230,6 +1230,7 @@ class PetitComputer //print(sbe.to!string); writeln(sbe.to!string); writeln(sbe.getErrorMessage2); + writeln(sbe.func); loc = vm.currentLocation; console.print(loc.line, ":", loc.pos, ":", parser.getLine(loc)); }