Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping Errors

Status
Not open for further replies.

mkohl

Programmer
Feb 22, 2005
82
US
I am not sure if I changed a setting, but for some reason when I get an error, my browser does not display any error message? Does, any one have a clue on what is going on. My basic code looks someone like this:

try
'code
catch
throw ex
finally
'code
end try

I am not sure what is going on but when it does throw the ex nothing is displayed in the browser.. also just to let you know in my browser settings I do not have"show friendly HTTP message" selected (I've tried selecting it and deselecting it). Any help would greatly be appreciated.

-mike
 
What messages, and how do you show them in the "catch" section (as if you don't write anything, nothing will be displayed!)?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I never had a problem before throwing a generic exception without a message.

-mike
 
I'm not sure I understand. Why would you throw an error with no error text? Wouldn't you want to do something like this:
Code:
        Try
            ' Code with error
        Catch ex As Exception
            ' Handle the error by emailing/saving/exporting the details somewhere
            HandleMyError(ex)
            ' Show a nice friedly message to the user
            MyErrorLabel.Text = "Sorry, an error occurred"
        Finally
            'code
        End Try



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
You have never thrown a generic exception without a message, and then programmed for that exception? This asp.net has not gone live.
 
No need to respond, I tested my code in a different browser, and it displayed the error I needed to see.. now I can program for it.

-mike
 
You have never thrown a generic exception without a message, and then programmed for that exception?
Nope. I'd rather handle my errors more like I've done above (where the real error is recorded elsewhere and a simple message is shown on screen).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Question? So, If I display a message such as the one you previously stated. Where would the errors be logged? Is there a directory that has a list of recorded errors?

-mike
 
You can write your own code to log them wherever you need to log them (i.e I log mine by sending an email, storing a record in a database and by writing to the event log on the server).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I suggest making a database to hold nothing but errors. That way you can create a .dll that you can share among everyone so that error logging is done the same way for everyone (if you are in an IT shop). Many people create an error table within each application database, but if you create one centralized database then you can have a central repository for the errors. This can be querried in the future to find out all sorts of things (i.e. common errors throughout all apps, which app has the most errors, etc). I tried to create a web service to do this but found out that exceptions are not serializable (all that work for nothing), which is why I went with the .dll.
 
Whether or not exception info gets displayed to the client depends on the configuration of the customErrors section of web.config:


...however, generally speaking you don't want the client seeing exception info because it may end up exposing sensative information (like connection strings).

It's better to work with the error in the global.asax Application_Error handler or via the redirect urls configured in the web.config customErrors element (or subelements).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top