Currently, if an uncaught error occurs in an ApplyHandler function passed to wrapMethod or wrapAccessor, it may break a third-party code that invoked a wrapped function. Furthermore, if such an error occurs before the original function -- usually denoted by orig variable in implementations -- is called, the original function will end up not being called.
The problem is that our code is called from third-party code and such code may not have exception handling (rightfully so in many cases).
What we should do is to make wrapMethod implementation explicitly handle errors. To do so, we need to change the interface of ApplyHandler. A tentative plan is to make it accepts a parameter origCaller, which is supposed to be called only once during a control flow of ApplyHandler. wrapMethod implementation should wrap invocation of ApplyHandlers with try-catch block, and if origCaller is not called, it should call the default apply handler and log errors so that we can fix in future versions.
Additionally, in dev version, if origCaller is called more than once, we should throw an error in the wrapped function.
Currently, if an uncaught error occurs in an
ApplyHandler
function passed towrapMethod
orwrapAccessor
, it may break a third-party code that invoked a wrapped function. Furthermore, if such an error occurs before the original function -- usually denoted byorig
variable in implementations -- is called, the original function will end up not being called.The problem is that our code is called from third-party code and such code may not have exception handling (rightfully so in many cases).
What we should do is to make
wrapMethod
implementation explicitly handle errors. To do so, we need to change the interface ofApplyHandler
. A tentative plan is to make it accepts a parameterorigCaller
, which is supposed to be called only once during a control flow ofApplyHandler
.wrapMethod
implementation should wrap invocation ofApplyHandler
s withtry-catch
block, and iforigCaller
is not called, it should call the default apply handler and log errors so that we can fix in future versions.Additionally, in dev version, if
origCaller
is called more than once, we should throw an error in the wrapped function.