  | |  | RE: Exception Handling Opinion | RE: Exception Handling Opinion 2004-12-13 - By Tim Weaver
I've been going over something very similar. We already have an infrastructure that allows customized messaging so the question for us what is the best way to get that message to the UI. The problem with exceptions is that we were seeing developers use: catch(Exception ex) { string error = ex.Message; } and then add the error string to the page. This is a really dangerous way to go (IMO). There is no guarantee that the information returned from the message property should be shown to the user. It is a big security risk to just blindly reflect error messages.
The solution we ended up with is that we created custom exception(s). The base custom exception overrides the Message property and returns the "messagized" text. This way the developers can do catch(SafeException ex) { string error = ex.Message;
} and always know that they will be given back text to show to the end user. They don't catch anything except the base exception and those derived from it. All other exceptions go to a generic error page that logs the issue and tells the user we had a problem.
On Mon, 13 Dec 2004 11:39:41 -0500, Jason Gaylord <jgaylord@(protected)> wrote: > I am creating a new web application where I want to allow some end users to customize messages for specific business rules. For instance, if a user attempts to login, I want to kick off an exception. Then, the user would be shown a customized message. > > I figure I need an HttpHandler to effectively handle the message portion. However, I can't think of a good solution to raise an error or throw an exception. I have other exceptions such as a 404. > > Any suggestions? > > Best Regards, > Jason N. Gaylord > Microsoft MVP, ASPInsider > http://www.jasongaylord.com > jgaylord@(protected) > --- > [This E-mail scanned for viruses by Declude Virus] > > Need SQL Advice? http://sqladvice.com > Need RegEx Advice? http://regexadvice.com > Need XML Advice? http://xmladvice.com >
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
|
|
 |