![]() |
|
|
Error Handling No matter how good a programmer you are you will undoubtedly make
mistakes in your code, so its good programming to write code to cope
with this eventuality.You can easily trap and turn nasty error messages
into easy on the eye messages that the user can understand.
<%
On Error resume Next %> This four word combination is used to tell the server to resume the next line of code if it stumbles upon an error, the ASP script will continue to execute instead of throwing up an exception. The following code will display the error number, description and source. <% Here's a version of the above code slightly better formatted; <% "On Error Resume Next" is usually placed at the top of each page. Below is an example with all the code coupled together: <% Even though the code has come across an error there will be no ugly error message displayed and the execution of the code will continue. As there is an error the description, number and source will be written out. Note that the following two lines of code are the same:
If Err.Number <> 0 Then
If Err <> 0 Then
Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|