PC Review


Reply
Thread Tools Rate Thread

do try/catches cascade?

 
 
darrel
Guest
Posts: n/a
 
      9th Aug 2005
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



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      9th Aug 2005
"darrel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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?


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


 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      9th Aug 2005
> What did you observe when you tried it for yourself...?

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

-Darrel


 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      10th Aug 2005
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.

"darrel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      10th Aug 2005
> 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.


Thanks, Kevin. That explains it nicely.

-Darrel


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lets hope it catches on here !! Abarbarian General Discussion 10 26th Aug 2009 09:09 PM
Multiple Catches in Try/Catch zacks@construction-imaging.com Microsoft VB .NET 3 16th Jan 2006 06:07 PM
terminating multiple try/catches darrel Microsoft ASP .NET 6 6th Apr 2005 08:16 PM
9500 Pro catches fire! Faustus DIY PC 4 30th Nov 2004 02:37 PM
try-catches Tim923 Microsoft C# .NET 9 29th Oct 2004 03:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:37 PM.