
ErrorCode | 309
HttpException
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Throw New HttpException(integer, string, integer)
Throws an HttpException whose GetHttpCode method returns the first
integer value passed into the constructor, whose Message property is set to
the value of the string passed into the constructor, and whose ErrorCode
property is set to the value of the second integer passed into the constructor.
Properties Reference
ErrorCode
integer = HttpException.ErrorCode
Returns an integer representing the Win32 error code or HRESULT of the exception.
This property is especially useful in situations when you are working with COM
objects through COM Interop and need to return or evaluate the
HRESULT returned
from a COM object failure. When creating HttpException instances in your own
code, you can use one of two overloaded constructors (shown earlier in the
“Comments/Troubleshooting” section) to set this property for HttpExceptions
that you throw.
Parameter
integer
An integer that will receive the
HRESULT or Win32 error code from the
property.
Example
The code example uses the Page_Load event handler to throw an HttpException
with a custom error message and error code, and then uses structured exception
handling to catch the exception and display the error message and error code as
the text of an ASP.NET Label control:
Sub Page_Load( ...