?
Solved

Determining Exception Type

Posted on 2009-07-09
2
Medium Priority
?
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
williamcampbell earned 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 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