MCPcopy Create free account
hub / github.com/dop251/goja / throw

Method throw

func.go:1004–1033  ·  view source on GitHub ↗
(v Value)

Source from the content-addressed store, hash-verified

1002}
1003
1004func (g *generatorObject) throw(v Value) Value {
1005 g.validate()
1006 if g.state == genStateSuspendedStart {
1007 g.state = genStateCompleted
1008 }
1009 if g.state == genStateCompleted {
1010 panic(v)
1011 }
1012 if d := g.delegated; d != nil {
1013 res, done := g.tryCallDelegated(func() (Value, bool) {
1014 method := toMethod(g.delegated.iterator.self.getStr("throw", nil))
1015 if method != nil {
1016 return g.callDelegated(method, v)
1017 }
1018 g.delegated = nil
1019 d.returnIter()
1020 panic(g.val.runtime.NewTypeError("The iterator does not provide a 'throw' method"))
1021 })
1022 if !done {
1023 return res
1024 }
1025 if g.state != genStateSuspendedYieldRes {
1026 res = nil
1027 }
1028 g.state = genStateExecuting
1029 return g.step(g.gen.next(res))
1030 }
1031 g.state = genStateExecuting
1032 return g.step(g.gen.nextThrow(v))
1033}
1034
1035func (g *generatorObject) _return(v Value) Value {
1036 g.validate()

Callers 1

enterNextFinallyFrameMethod · 0.45

Calls 10

validateMethod · 0.95
tryCallDelegatedMethod · 0.95
callDelegatedMethod · 0.95
stepMethod · 0.95
toMethodFunction · 0.85
returnIterMethod · 0.80
NewTypeErrorMethod · 0.80
nextThrowMethod · 0.80
getStrMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected