MCPcopy Create free account
hub / github.com/buke/quickjs-go / forceRuntimeEvalFailureForTest

Function forceRuntimeEvalFailureForTest

runtime.go:1538–1553  ·  view source on GitHub ↗
(enable bool)

Source from the content-addressed store, hash-verified

1536}
1537
1538func forceRuntimeEvalFailureForTest(enable bool) func() {
1539 oldHook := runtimeEvalFunctionHook
1540 if enable {
1541 runtimeEvalFunctionHook = func(ctx *C.JSContext, compiled C.JSValue) C.JSValue {
1542 C.JS_FreeValue(ctx, compiled)
1543 msg := C.CString("forced eval failure")
1544 defer C.free(unsafe.Pointer(msg))
1545 return C.ThrowInternalError(ctx, msg)
1546 }
1547 } else {
1548 runtimeEvalFunctionHook = nil
1549 }
1550 return func() {
1551 runtimeEvalFunctionHook = oldHook
1552 }
1553}

Calls 1

ThrowInternalErrorMethod · 0.80