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()
%>
</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
%>
<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
%>
Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.
|