Exception Handling

Q

Q2004

I am creating my own exception handling class derived from Exception. It is
used to handle tcp connection. Whenver connection failed, it throws an
exception. My question is:

How do I make my exception class to stop further exception from being
re-thrown after the errror is handled/processed ?
 
D

Dmitriy Lapshin [C# / .NET MVP]

Classes derived from System.Exception (Microsoft recommends inheriting from
System.ApplicationException for such purpose, by the way) represent custom
exceptions, they are not used to *handle* exceptions.

You should rather use the try..catch..finally construct to handle
exceptions. If you don't place the throw statement somewhere in the "catch"
clause, the exception won't be re-thrown.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top