wrapVMError wraps a VM execution error with a context prefix and logs it.
(context string, err error)
| 86 | |
| 87 | // wrapVMError wraps a VM execution error with a context prefix and logs it. |
| 88 | func 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 |
no test coverage detected