| 386 | } |
| 387 | |
| 388 | func (l *State) throw(errorCode error) { |
| 389 | if l.protectFunction != nil { |
| 390 | panic(errorCode) |
| 391 | } else { |
| 392 | l.error = errorCode |
| 393 | if g := l.global.mainThread; g.protectFunction != nil { |
| 394 | g.push(l.stack[l.top-1]) |
| 395 | g.throw(errorCode) |
| 396 | } else { |
| 397 | if l.global.panicFunction != nil { |
| 398 | l.global.panicFunction(l) |
| 399 | } |
| 400 | log.Panicf("Uncaught Lua error: %v", errorCode) |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | func (l *State) protect(f func()) (err error) { |
| 406 | nestedGoCallCount, protectFunction := l.nestedGoCallCount, l.protectFunction |