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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Common Error Handling

Status
Not open for further replies.

Mannga

Programmer
Jun 21, 2002
85
GB
Hi All,

I am trying to create something that will handle all my error handling in one spot.

I would like to be able to do something like this.

try
{
//code here...
}
catch( Exception exc )
{
ErrorHandler.Function(exc)
}

and then my error handler will write the error into my log file, popup a message box to let the user know that he broke something :)... and then coninue.

I can do all the error handling but where would I put the error handling function so that is can be called from anywhere and can still use MessageBoxes?

Thanks,
Gavin Mannion
 
Just an idea - why don't you have your error handling function return an error message, after doing the logging - and handle the error message returned in the function?
 
I have thought of doing it this way but not only does that mean I need to write an extra line of code in every try/catch statement but there are also a few more reasons why I would like to know if it is possible to popup windows from a seperate thingie :)... like a class.

 
Well to answer my own question ;-)

I created a Component added the line
using System.Windows.Forms
and it does everything I need it to now... simple but it works

Thanks for the input

Cheers,
Gavin
 
Hi Manga,

Interested to know how you do it. Can you post the code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top