Solved

Determining Exception Type

Posted on 2009-07-09
2
210 Views
Last Modified: 2013-12-17
In my application, I am using the global.asax's Application_Error to manage all unhandled exceptions -- essentially, I log the exception and redirect the user to specified error page.  

I have introduced a new entry point into my application that requires two parameters.   If either of the parameters are not available, I throw a custom exception to specifically identify this new error type.   The problem is, I'm not sure how to differentiate in the global.asax between this specific exception [I've defined it as MonthlyBreakdownException] and all other exceptions.      How can I obtain the specific error type [MonthlyBreakdownException] in my code below?

I'm using Visual Studio 2005, C#
Here is my code that I'm using currently:
 

        Exception ex = Server.GetLastError().GetBaseException();

        Logger.LogError(ex);
 

//I'd like to check for my new error here//
 

        if (Session["sessionId"] == null)

        {

            Response.Redirect("SystemTimeout.aspx", true);

        }

        else

        {

            Response.Redirect("LandingPage.aspx?sessionid=" + "none", true);

         }

Open in new window

0
Comment
Question by:escheider
2 Comments
 
LVL 12

Accepted Solution

by:
williamcampbell earned 250 total points
ID: 24816234
Check the Type?
Exception ex = Server.GetLastError().GetBaseException();
 

if ( ex.GetType () == "MonthlyBreakdownException" )

{

    // Woop!

}

Open in new window

0
 
LVL 4

Author Closing Comment

by:escheider
ID: 31602049
Thanks .. didn't realize it was that simple.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now