Error handler not triggered

Discussion in 'AutoCAD' started by Arnaud Lesauvage, Feb 18, 2005.

  1. Hi everyone !

    I have a Sub calling another Sub.
    The second Seb has an error handler, but surprisingly, it does not
    work. Instead, the execution breaks just as if there was no error
    handler, with a msgbox "error blablabla.... End / Debug / Cancel".
    Can someone explain this behaviour ?

    Thanks a lot for helping !

    Arnaud
     
    Arnaud Lesauvage, Feb 18, 2005
    #1
  2. Your primary sub is probably handling the secondary subs error. Typically
    you only apply error handling at the lowest levels so, for example, sub 1
    has no error handling and relies on the error handling of sub 2.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Feb 18, 2005
    #2
  3. There was no error handler in the first sub.
    I found the problem though : there was an error in the error
    handler ! According to the VBA help file, in this case the program
    breaks at the place of the first error, and that was exactly what
    was happening.
    I wanted to highlight faulty entities in a "for each ... next"
    loop by changing their color, and that was a very bad idea.
    I now use a "On Error Resume Next" handler with a check at
    critical places (if err.number<>0 then ...)

    Thanks for helping though !

    Arnaud
     
    Arnaud Lesauvage, Feb 18, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.