Codefixer - ASP tutorials, resources and software
New MS SQL 2008 Available – DiscountASP.NET
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Monday 6 October
MembersPro PayPal - ASP Membership software

USA & Europe Data Centers – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Advanced Error Handling in ASP

Below is a slightly more advanced script to deal with an error. It uses an include file which you should put in the same folder as the page that calls it or if you know how to use a virtual include then work that way.

<html>
<head>
<title>Error Handling</title>
</head>

<body>
<!--#include file="error_checker.asp"-->

<%
respons.write ("this will produce an error as there is a mispelling")

ErrorCheck()     'this calls the function which will check if there is an error
'you can call this function anywhere on your page
'it will only check errors in the previous code
%>
</body>
</html>

Ok so now we will write the include file that will hold the Errorcheck funtion and deal with any errors encountered in the code.

Below is the file that should be called error_checker.asp

<%
On Error Resume Next
Function ErrorCheck()
If Err.Number<>0 then    'if there is an error then the html table will be written out
%>
<table width="80%" border="0" align="center">
<tr>
<td>Error is <%= Err.description%> and Error no. is <%=Err.number%>
</td>
</tr>
<tr>
<td>Please report the error to our webmaster @ <a href="mailto:webmaster@codefixer.com">webmaster@codefixer.com</a>
</td>
</tr>
</table>

<%
End If
End Function
%>

LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software