
312
|
Chapter 15: The HttpException Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Message.Text = "ERROR:<br/>"
Message.Text &= "Message: " & HttpEx.Message & "<br/>"
End Try
End Sub
Notes
The ease with which the Message property can be accessed makes it tempting to
simply display this property when an error occurs. A better approach to error
handling, however, is to log this information either in the NT Event Log or in
your own private application log and handle the error to the user transparently.
This provides you with better information to troubleshoot your applications and
gives your users a more satisfying (and less frustrating) experience.
Source
string = HttpException.Source
HttpException.Source = string
Sets or returns a string representing the source of the exception. For custom
exceptions that you create and throw, this code may be set to the name of the
method and/or class from which the exception is thrown.
Parameter
string
A string that will receive the value from the property.
Example
The code example causes an exception by attempting to set a Session value on a
page for which the
enableSessionState attribute of the @ Page directive has been
set to
False. The example code then displays the resulting error message and
source:
<%@ Page Language="vb" EnableSessionState="false" %>
...
Sub Page_Load( )
Try
Session("foo") = "Foo" ...