Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022


Handling ASP Errors

ASP will let you know an error occurs, usually by displaying the message "The page cannot be displayed" along with the code "HTTP 500 - Internal Server Error - ASP Error - Internet Information Sever" and a terse message giving some usually not too helpful information about what caused the error. This is NOT the type of message you want to send to your Web site's visitor.

ASP errors are basically of two types. The first type is "syntax" errors or "logic" errors caused by the programmer. The second type "run-time" errors generated by the system. Examples of system errors are a file or database that ASP can't perform an operation on because of low system resources of a loss of connectivity.

There are two ways to respond to an error. The first way is to just let them happen and expose your Web site's visitors to the default error message, or by "Handling" the error. Handling the error involves determining where an error might occur in your code, for example in code that accesses a file or database, and adding code to do something about the error.

Things you might do about an error are display a friendly error message to the user, perform any clean up tasks required by the error, log the error, or notify the webmaster of the error.

There are two ways to handle an error. The first way is to use VBScript's "On Error Resume Next" statement. Below is an example of using the "On Error" statement.

<%
Set cn = CreateObject("ADODB.Connection")

On Error Resume Next
cn.Provider = "sas.localprovider.1"
cn.Properties("Data Source") = "c:\testdata"
cn.Open
cn.Close
%>

This code creates a database connection, configures the connection, and then opens and closes the connection. If an error occurs when attempting to configure and use the database connection, the "On Error Resume Next" will cause execution of the code to continue on the next line after the line that caused the error.

The "On Error Resume Next" stops the default error message from appearing and allows the webpage to continue execution, but it doesn't do anything about the error.

The second way to handle an error is to use the Err object. The properties and methods of the Err object are listed below.

Properties

.Number
.Description
.Source

Methods

.Clear
.Raise

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2017 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268