MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / runCallable

Function runCallable

internal/scripting/vmwrapper.go:103–114  ·  view source on GitHub ↗

runCallable executes fn under timeout and returns the result. On error the raw VM error is logged and returned; the caller should wrap it with additional context (e.g. the function name) before surfacing to callers.

(vmw *VMWrapper, timeout time.Duration, fn goja.Callable, args ...goja.Value)

Source from the content-addressed store, hash-verified

101// On error the raw VM error is logged and returned; the caller should wrap it
102// with additional context (e.g. the function name) before surfacing to callers.
103func runCallable(vmw *VMWrapper, timeout time.Duration, fn goja.Callable, args ...goja.Value) (goja.Value, error) {
104 tmr := time.AfterFunc(timeout, func() {
105 vmw.VM.Interrupt(errTimeout)
106 })
107 res, err := fn(goja.Undefined(), args...)
108 vmw.VM.ClearInterrupt()
109 tmr.Stop()
110 if err != nil {
111 return nil, wrapVMError("call", err)
112 }
113 return res, nil
114}

Callers 15

TrySpellScriptEventFunction · 0.85
TryRoomScriptEventFunction · 0.85
TryRoomTryEnterEventFunction · 0.85
TryRoomTryExitEventFunction · 0.85
TryRoomIdleEventFunction · 0.85
TryRoomCommandFunction · 0.85
TryItemScriptEventFunction · 0.85
TryItemCommandFunction · 0.85
TryItemTryPurchaseEventFunction · 0.85
TryBuffScriptEventFunction · 0.85
TryBuffCommandFunction · 0.85
TryPetScriptEventFunction · 0.85

Calls 1

wrapVMErrorFunction · 0.85

Tested by

no test coverage detected