My testing seems to indicate that it won't, but no documentation I can find
explicitly states this. Let's say I throw a customer exception like this:
Try
m = New MyObject
Catch ex As Exception
Throw New MyObjectCreationFailedException(<stuff>)
LaunchNuclearMissiles()
End Try
Will the world ever get annihilated?
(I don't know WHY I thought I could put cleanup code after a Throw
statement, but I tried anyway and while stepping through in the debugger I
noticed that I was jumping out of the procedure as soon as the error was
thrown. Oops!) 6 1904
Hi Jeff
Just one statement missing:
Try
m = New MyObject
Catch ex As Exception
Throw New MyObjectCreationFailedException(<stuff>)
Finally
LaunchNuclearMissiles()
End Try
HTH
Charles
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl... My testing seems to indicate that it won't, but no documentation I can
find explicitly states this. Let's say I throw a customer exception like this:
Try m = New MyObject Catch ex As Exception Throw New MyObjectCreationFailedException(<stuff>)
LaunchNuclearMissiles() End Try
Will the world ever get annihilated?
(I don't know WHY I thought I could put cleanup code after a Throw statement, but I tried anyway and while stepping through in the debugger I noticed that I was jumping out of the procedure as soon as the error was thrown. Oops!)
"Charles Law" <bl**@thingummy.com> wrote in message
news:Oj**************@TK2MSFTNGP10.phx.gbl... Just one statement missing:
Try m = New MyObject Catch ex As Exception Throw New MyObjectCreationFailedException(<stuff>) Finally LaunchNuclearMissiles() End Try
That wasn't what I was asking. I want to run cleanup code ONLY if an
exception occurs, and I wanted to know if using Throw absolutely, positively
exits a procedure without running any other statements that follow it
(Finally blocks notwithstanding; I know they're ALWAYS executed). Perhaps I
should have asked it as "Will any more code in a given Catch block run after
a Throw statement?"
Ah, yes, I see what you mean.
I would not expect any code to execute after the Throw. Could you not just
execute the clean-up in the Catch block, but before the Throw? Otherwise,
you would have to use a flag to select the code you want to run in the
Finally block.
Charles
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:em**************@TK2MSFTNGP10.phx.gbl... "Charles Law" <bl**@thingummy.com> wrote in message news:Oj**************@TK2MSFTNGP10.phx.gbl...
Just one statement missing:
Try m = New MyObject Catch ex As Exception Throw New MyObjectCreationFailedException(<stuff>) Finally LaunchNuclearMissiles() End Try That wasn't what I was asking. I want to run cleanup code ONLY if an exception occurs, and I wanted to know if using Throw absolutely,
positively exits a procedure without running any other statements that follow it (Finally blocks notwithstanding; I know they're ALWAYS executed). Perhaps
I should have asked it as "Will any more code in a given Catch block run
after a Throw statement?"
"Charles Law" <bl**@thingummy.com> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl... Ah, yes, I see what you mean.
I would not expect any code to execute after the Throw. Could you not just execute the clean-up in the Catch block, but before the Throw?
Yes, and I rearranged my code to do so. I just cannot find concrete
documentation that says that Throw forces (i.e., guarantees) an exit from a
procedure.
Jeff Johnson [MVP: VB] wrote: "Charles Law" <bl**@thingummy.com> wrote in message news:ub**************@TK2MSFTNGP09.phx.gbl...
Ah, yes, I see what you mean.
I would not expect any code to execute after the Throw. Could you not just execute the clean-up in the Catch block, but before the Throw?
Yes, and I rearranged my code to do so. I just cannot find concrete documentation that says that Throw forces (i.e., guarantees) an exit from a procedure.
I'm not sure that it is explicitly stated in this manner, but since throwing
an exception causes an immediate search up the call stack for an error
handler, it is guarenteed for this to be the case... In other words,
control will be immediately passed to the next error handler.
Tom Shelton
"Tom Shelton" <to*@mtogden.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I'm not sure that it is explicitly stated in this manner, but since
throwing an exception causes an immediate search up the call stack for an error handler, it is guarenteed for this to be the case... In other words, control will be immediately passed to the next error handler.
Right, that I've seen. I just want warm and fuzzies that searching for an
error handler isn't like calling a subroutine: i.e., that control WON'T
return to the statement after the Throw once the error has been handled. I'm
pretty sure it won't (since it hasn't yet), but it's the kind of thing that
should be stated in the docs. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dterrors |
last post by:
Will php 6 do strong typing and/or namespaces?
I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better. I didn't even know there was
a...
|
by: Antoon Pardon |
last post by:
I have had a look at the signal module and the example
and came to the conclusion that the example wont work
if you try to do this in a thread.
So is there a chance similar code will work in a...
|
by: Soren Kuula |
last post by:
Hi, everyone,
I'm beginning work on my Master's thesis in computer science ...
I will start out with a pretty advanced, not yet published algorithm for
computing quite accurate control flow...
|
by: Egbert Nierop \(MVP for IIS\) |
last post by:
Hi,
I'm 'improving' CComBSTR (yes, I do still program unmanaged code in addition
to C# ) to contain features, not found in it.
Does anybody have good code which maches LastIndexOf()?
If...
|
by: Swaregirl |
last post by:
Hello,
I would like to build a website using ASP.NET. I would like website
visitors to be able to download code that I would like to make available to
them and that would be residing on my...
|
by: Ryan Liu |
last post by:
Hi,
In the .NET Framework SDK documentation, I can see DataRow.AcceptChanges
method will throw RowNotInTableException exeception.
And in DataTable.AcceptChanges(), the documentation does not...
|
by: Phlip |
last post by:
C++ers:
I have this friend who thinks C++ cannot throw from a destructor.
I think throwing from a destructor is bad Karma, and should be designed
around, but that C++ cannot strictly prevent...
|
by: siddhu |
last post by:
What happens when deletion falis?Does operator delete function throw
exception?
I assume that nothrow is not available with delete. Or is it available?
|
by: Ranganath |
last post by:
Why is throw keyword considered as an operator?
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |