TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ryan Brown
NA
9
0
How to get the type of an exception
May 29 2009 10:21 AM
Hello all,
I am tasked with creating a base exception handler that will handle a
bunch of clean-up that needs to happen based on the type of exception
thrown. So, for example, I will have (at least in my initial thoughts)
a base class like:
public abstract class BaseExceptionHandler
{
public void HandleException(Exception ex)
{
Do something based on exception type;
}
}
Then each inherited exception type will declare like:
public abstract class NewExceptionHandler : BaseExceptionHandler
{
Any new or overridden logic
}
Then the implementation needs to look like:
NewExceptionHandler exHandler = new NewExceptionHandler();
try
{
Whatever
}
catch (MissingDependencyException ex)
{
exHandler.HandleException(ex);
}
catch (DividebyzeroException ex)
{
exHandler.HandleException(ex);
}
…
How, given that all of these inherit from Sytem.Exception do I find
out the actual type of the exception thrown? I know I am missing
something obvious…
Thanks in advance!
rbr
Reply
Answers (
2
)
What happens when you change the web.config file at run time?
easy! need to calculate one text box when the user enters data into another text box.