Print error message and exit program with status 1.
package vm
import (
+ "fmt"
+ "os"
"sync"
)
@@ -29,9 +31,14 @@ func (s *stack) push(v *Pointer) {
s.Data[s.thread.sp] = v
}
- if _, ok := v.Target.(*Error); ok {
+ if err, ok := v.Target.(*Error); ok {
cf := s.thread.callFrameStack.top()
cf.pc = len(cf.instructionSet.instructions)
+
+ if s.thread.vm.mode == NormalMode {
+ fmt.Println(err.Message)
+ os.Exit(1)
+ }
}
s.thread.sp++
