Results 1 to 3 of 3

Thread: raising error from class module to be caught in regular (bas) module

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    4

    raising error from class module to be caught in regular (bas) module

    I ran into this while working on http://www.vbforums.com/showthread.php?t=350844. Basically, I was making a call to a pulic function in my class module from a regualr module (bas) who's job is to check for the presense of an error in a class local variable and raise a VB error if there is one. The class mod function does not have an error handler as the point is to have VB bubble the error upto the calling function to be trapped in it's error handing.

    I just thought this was an interesting point (to me anyhow) as my observations means one of the following is true:
    a) VB error messages cannot be moved up the call stack across modules
    b) VB error messages cannot be moved up the call stack between class and regular modules
    c) a and b

    I'm suspecting b, but am curious as you you're observations.

    Eric

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: raising error from class module to be caught in regular (bas) module

    I don't think either of a or b is true. VB errors propagate up the call stack until they either reach an error handler or run out of stack.

    If you have a class module function called from a standard module and an error handler in the procedure calling the class method then any errors raised from the class method will be handled in the calling procedure in the standard module.

  3. #3
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: raising error from class module to be caught in regular (bas) module

    Yeah penagate is right.

    You would have to trap the HRESULT and clear it to stop it moving up the callstack.

    THis sounds more like an 'event' in a class that you have not declared WithEvents.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width