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

Function wrapVMError

internal/scripting/vmwrapper.go:88–98  ·  view source on GitHub ↗

wrapVMError wraps a VM execution error with a context prefix and logs it.

(context string, err error)

Source from the content-addressed store, hash-verified

86
87// wrapVMError wraps a VM execution error with a context prefix and logs it.
88func wrapVMError(context string, err error) error {
89 finalErr := fmt.Errorf("%s: %w", context, err)
90 if _, ok := finalErr.(*goja.Exception); ok {
91 mudlog.Error("JSVM", "exception", finalErr)
92 } else if errors.Is(finalErr, errTimeout) {
93 mudlog.Error("JSVM", "interrupted", finalErr)
94 } else {
95 mudlog.Error("JSVM", "error", finalErr)
96 }
97 return finalErr
98}
99
100// runCallable executes fn under timeout and returns the result.
101// On error the raw VM error is logged and returned; the caller should wrap it

Callers 2

loadVMFunction · 0.85
runCallableFunction · 0.85

Calls 1

ErrorFunction · 0.92

Tested by

no test coverage detected