MCPcopy Index your code
hub / github.com/didi/mpx / wrapMethodsWithErrorHandling

Function wrapMethodsWithErrorHandling

packages/utils/src/errorHandling.js:17–32  ·  view source on GitHub ↗
(methods, instance)

Source from the content-addressed store, hash-verified

15}
16
17export function wrapMethodsWithErrorHandling (methods, instance) {
18 // if (process.env.NODE_ENV === 'production') return methods
19 const newMethods = {}
20 Object.keys(methods).forEach((key) => {
21 // worklet 函数重新赋值会变成普通函数,这里只处理非worklet函数
22 // 微信小程序&RN worklet都有数值类型的 __workletHash
23 if (isFunction(methods[key]) && !methods[key].__workletHash) {
24 newMethods[key] = function (...args) {
25 return callWithErrorHandling(methods[key].bind(this), instance || this?.__mpxProxy, `component method ${key}`, args)
26 }
27 } else {
28 newMethods[key] = methods[key]
29 }
30 })
31 return newMethods
32}

Callers 6

initSetupMethod · 0.90
filterOptionsFunction · 0.90
getDefaultOptionsFunction · 0.90
filterOptionsFunction · 0.90
getDefaultOptionsFunction · 0.90
filterOptionsFunction · 0.90

Calls 4

isFunctionFunction · 0.90
callWithErrorHandlingFunction · 0.85
forEachMethod · 0.80
keysMethod · 0.80

Tested by

no test coverage detected