MrNorth Posted October 6, 2003 Posted October 6, 2003 I am starting to build a web application, and I have learned all the tricks of OO programming like interfaces polymorphism and so on. I am only having problems converting the theory into practise... I want to create a generic class that works as an "error handler", meaning that I will use this in all the "catch" statements in my rather large asp.net application. Which is the best way to do this, and perhaps the .net framework has an even better way to handle errors? I want the ability to log custom messages and exception messages. Can I use OO in any way here? kind regards Henrik Quote
jeffchs Posted October 6, 2003 Posted October 6, 2003 I'm not sure I know exactly what you need but here is what I would do: use this in your try/catch try { // whatever you're trying to do } catch(Exception ex) { MyCustomErrorCatch(ex); } void MyCustomErrorCatch(Exception myCaughtException) { Response.Write(myCaughtException.ToString()); // you can write this out to the browser, a file, a database or what ever else } Quote
Roey Posted October 6, 2003 Posted October 6, 2003 Are you thinking along the lines of an Exception class that can be called rather than writing the Try..Catch...End statements each time ? Quote
MrNorth Posted October 6, 2003 Author Posted October 6, 2003 Well, I was more thinking about some ideas about how to incorporate full error management for enterprise applications, like database logging etc etc... and how the .net exception class should be incorporated into that... Just some suggestions how to do the class specs for such a component. You see, on my company we are designing plenty of web applications for 100-5000 users, but the error management components for these appls are somewhat lacking, to say the least. And now with the OO design of .net I thought it might be wise to design a reusable component that can be used anywhere in the code-behind. Something every class can use, I was thinking about designing some kind of interface but since I haven't been able to find information about designpatterns for error management, I am kind of in the dark. We use the GRASP patterns for our software design... In short terms, I want to give error management a professional look and to fully use the concept of OO and reusable code. I dunno, perhaps it is enough to just write a class/interface that accepts an exception object and take action depending on that. But how about if the user want logging enabled, and what about write the trace log to file? How is error management components written in other projects/applications? Perhaps some could share your ideas-thoughts? Perhaps we have a discussion goin' on here ;) kind regards Henrik Quote
*Gurus* Derek Stone Posted October 6, 2003 *Gurus* Posted October 6, 2003 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp Quote Posting Guidelines
MrNorth Posted October 7, 2003 Author Posted October 7, 2003 ahh exactly what i was looking for, thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.