do try/catches cascade?

Discussion in 'ASP .Net' started by darrel, Aug 9, 2005.

  1. darrel

    darrel Guest

    Not sure if that's the proper term.

    Let's say I have this:

    function function1()
    try
    do something
    function2()
    catch
    error
    end try
    end function


    function function2()
    try
    do something
    catch
    error
    end try
    end function

    When function 1 is called, will it abort if function 2 also aborts? Or will
    function 1 do whatever it can regardless of whether function 2 aborts or
    not?

    -Darrel
     
    darrel, Aug 9, 2005
    #1
    1. Advertisements

  2. darrel

    Mark Rae Guest

    What did you observe when you tried it for yourself...?
     
    Mark Rae, Aug 9, 2005
    #2
    1. Advertisements

  3. darrel

    darrel Guest

    What did you observe when you tried it for yourself...?

    I'm not there yet...still building...will report back... ;o)

    -Darrel
     
    darrel, Aug 9, 2005
    #3
  4. Good question darrel.

    Exceptions "bubble up," which means that when an exception occurs, and is
    not handled, it is passed to the calling function. So, if the calling
    function doesn't handle it, it throws the same exception, which is then
    passed to the function that called IT. And so on. So, whether the exception
    bubbles up is determined by whether or not the exception is caught and
    handled gracefully in the function in which it is thrown.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Everybody picks their nose,
    But some people are better at hiding it.
     
    Kevin Spencer, Aug 10, 2005
    #4
  5. darrel

    darrel Guest

    Exceptions "bubble up," which means that when an exception occurs, and is
    Thanks, Kevin. That explains it nicely.

    -Darrel
     
    darrel, Aug 10, 2005
    #5
    1. Advertisements

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.