harbourCodeExtension
harbourCodeExtension copied to clipboard
Evaluating an Errorblock in an Error handler causes an error
In the program below if the debugging code is linked in then the current error handler is called recursively until it crashes.
procedure Main()
local bOldErrorBlock
local n
setMode(24, 80)
if hb_isFunction("__DebugItem")
? "Debugger linked in"
endif
bOldErrorBlock := ErrorBlock({ |e| HandleError(e, bOldErrorBlock, .t.) })
begin sequence
n++
recover
? "Recovered"
end sequence
ErrorBlock({ |e| HandleError(e, bOldErrorBlock, .f.) })
begin sequence
n++
recover
? "Recovered"
end sequence
ErrorBlock(bOldErrorBlock)
return
function HandleError(e, bOldErrorBlock, lCarryOn)
? "HandleError " + hb_ValToStr(lCarryOn)
if lCarryOn
break
endif
return eval(bOldErrorBlock, e)
I love your addin! Thanks, Alex.
The line where it calls the "wrong" error handler is 1190 in your current version of dbg_lib.prg (downloaded today):
eval(t_oDebugInfo['userErrorBlock'], e)
unluckily the errorblock management is a little messy on Harbour, on this particular case you can try using the BEGIN SEQUENCE WITH {| oErr | HandleError( oErr ) } syntax