File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ func main(){
6262 }
6363code := obj .(* py.Code )
6464v := vm .NewVm ()
65- v .Run (code )
65+ err = v .Run (code )
66+ if err != nil {
67+ log .Fatal (err )
68+ }
6669
6770}
Original file line number Diff line number Diff line change 22package vm
33
44import (
5+ "errors"
56"fmt"
67"github.com/ncw/gpython/py"
78)
@@ -777,7 +778,21 @@ func do_CALL_FUNCTION_VAR_KW(vm *Vm, argc int32){
777778}
778779
779780// Run the virtual machine on the code object
780- func (vm * Vm ) Run (co * py.Code ){
781+ //
782+ // FIXME figure out how we are going to signal exceptions!
783+ func (vm * Vm ) Run (co * py.Code ) (err error ){
784+ defer func (){
785+ if r := recover (); r != nil {
786+ switch x := r .(type ){
787+ case error :
788+ err = x
789+ case string :
790+ err = errors .New (x )
791+ default :
792+ err = errors .New (fmt .Sprintf ("Unknown error '%s'" , x ))
793+ }
794+ }
795+ }()
781796vm .co = co
782797ip := 0
783798var opcode byte
@@ -801,5 +816,5 @@ func (vm *Vm) Run(co *py.Code){
801816vm .extended = false
802817jumpTable [opcode ](vm , arg )
803818 }
804- // Return something?
819+ return nil
805820}
You can’t perform that action at this time.
0 commit comments