Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluating an Errorblock in an Error handler causes an error #77

Open
alexstrickland opened this issue May 28, 2021 · 2 comments
Open

Comments

@alexstrickland
Copy link

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.

@alexstrickland
Copy link
Author

alexstrickland commented May 29, 2021

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)

@APerricone
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants