Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Commit

Permalink
Avoid some common.Throw() usage
Browse files Browse the repository at this point in the history
Resolves #2 (comment)
  • Loading branch information
Ivan Mirić committed Aug 13, 2021
1 parent 65326ec commit 264ba62
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (*RootModule) NewModuleInstance(m modules.InstanceCore) modules.Instance {
err := o.DefineAccessorProperty(name, rt.ToValue(func() goja.Value {
obj, err := newInfo()
if err != nil {
common.Throw(mi.GetRuntime(), err)
common.Throw(rt, err)
}
return obj
}), nil, goja.FLAG_FALSE, goja.FLAG_TRUE)
Expand Down Expand Up @@ -127,7 +127,7 @@ func (mi *ModuleInstance) newScenarioInfo() (*goja.Object, error) {
},
}

return newInfoObj(rt, si), nil
return newInfoObj(rt, si)
}

// newTestInfo returns a goja.Object with property accessors to retrieve
Expand Down Expand Up @@ -162,7 +162,7 @@ func (mi *ModuleInstance) newTestInfo() (*goja.Object, error) {
},
}

return newInfoObj(rt, ti), nil
return newInfoObj(rt, ti)
}

// newVUInfo returns a goja.Object with property accessors to retrieve
Expand All @@ -188,18 +188,18 @@ func (mi *ModuleInstance) newVUInfo() (*goja.Object, error) {
},
}

return newInfoObj(rt, vi), nil
return newInfoObj(rt, vi)
}

func newInfoObj(rt *goja.Runtime, props map[string]func() interface{}) *goja.Object {
func newInfoObj(rt *goja.Runtime, props map[string]func() interface{}) (*goja.Object, error) {
o := rt.NewObject()

for p, get := range props {
err := o.DefineAccessorProperty(p, rt.ToValue(get), nil, goja.FLAG_FALSE, goja.FLAG_TRUE)
if err != nil {
common.Throw(rt, err)
return nil, err
}
}

return o
return o, nil
}

0 comments on commit 264ba62

Please sign in to comment.