1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

on error[msg] unexpected behaviour

Discussion in 'Support' started by igs, Jul 30, 2008.

  1. igs


    Jul 30, 2008
    Likes Received:

    it seems there is a strange or at least unexpected behaviour of the error handlers in 4NT/TCC. I first saw it in a little bit complex batch file.
    One point was that this batch file recursively calles itself. The batch debugger 'bdebugger' seems not to work for recursively called batch files.
    Even explicitly calling bdebugger in my batch file does not start the debugger.

    I have a common error handler which is initialized in an alias. In the current batch file there are some lines where the error handler should be disabled. After that the original error handler should be enabled again what does not work.

    on errormsg goto :error_handler
    rem do something
    on error goto :afterTrySomethingWhatMayFail
    rem try something what may fail
    rem restore the original error handler (what does not work) 
    on errormsg goto :error_handler
    rem do something again [block 2]
    If an error occures in [block 2] I would expect 4NT/TCC jumps to :error_handler. But no, it jumps to :afterTrySomethingWhatMayFail, what results in an endless loop in my batch file. This error handler is still active.

    From the documentation I would expect, that there can only be one exclusive error handler 'on error' OR 'on errormsg' active. When I insert an 'on error' statement after the label :afterTrySomethingWhatMayFail all works well. It seems that there is an 'on error' AND an 'on errormsg' handler and that the 'on error' handler take precedence over 'on errormsg'.

    If it is intended that there are two handlers 'on error' and 'on errormsg' active in parallel than at least there should be a hint in the documentation also stating which one takes precedence.


Share This Page