After everything else is done with your new piece of asp code, what
about errors? No matter how much time you have spent checking through
your code there is still the possibility of a logic error, or maybe
someone using your program can induce an error. System error
messages can easily be trapped and turned into something which looks
more preplanned and easier on the eye.
To trap errors we add <%on error resume%>at
the appropriate place in the code, usually at the start.. I have found
before that it has been necessary to place this at the start of a
subroutine.
Next after each section of code which is likely to cause an error, for example database connections, add the following:
If Err.number <> 0 then errorTrap 'if there is an error
And later in the code:
<%
Function errorTrap
response.write ("Sorry you have encoutered an error." & "<br>")
response.write ("Your error number is " & Err.number & "<br>")
response.write ("The error source is " & Err.source & "<br>")
response.write ("The error description is " & Err.description & "<br>")
End Function
%>
| This article viewed: 974 times | Back |
Copyright © 2004-2007 Janet Systems Ltd.