Print Page | Close Window

onError Command in ASP ?!?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10255
Printed Date: 31 March 2026 at 4:31pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: onError Command in ASP ?!?
Posted By: neotrix
Subject: onError Command in ASP ?!?
Date Posted: 02 May 2004 at 7:26am

Hello All,

I wanted to ask is there any onError Kindov a command in asp ?

For example, if i try to open a file using server.execute and the file is not there, could there be a command with the help of which i can write a custom error message ?

i just wrote

Server.Execute(songlyrics)
onError(Server.Execute("error.asp"))

I dont think this works, is there any command that may do this ?thanks in advance.



-------------
http://www.muhammadbinyusrat.com/blog/" rel="nofollow - Say to the believing men..



Replies:
Posted By: Semikolon
Date Posted: 02 May 2004 at 8:09am

<%
On Error Resume Next 'Resume to the next line if error

... ... ...

If Err.Number <> 0 Then  'If there is an error
 ... ... ...    'Action to perform if there is an error
End If
%>



Posted By: neotrix
Date Posted: 02 May 2004 at 8:29am

ThaaaankkkkkkkkkkYouuuuuuuuuuuu

^_^



-------------
http://www.muhammadbinyusrat.com/blog/" rel="nofollow - Say to the believing men..


Posted By: dpyers
Date Posted: 02 May 2004 at 1:55pm
Won't work. Sever executes and includes are resolved when the asp page loads - not when the script executes.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Semikolon
Date Posted: 02 May 2004 at 1:59pm
for includes it wont work, but with server.execute it works fine

ServerSideIncludes is Pre-processing, but Server.* Commands is not.


Posted By: Mart
Date Posted: 02 May 2004 at 5:58pm
Originally posted by dpyers dpyers wrote:

Try this.

Create 2 asp pages - calling.asp and called.asp.

In calling.asp, paste this code...

<%
'On Error Resume Next
Server.Execute("called.asp")
If Err.Number <> 0 then
 response.write Err.Number & " - " & Err.Description & "<BR>"
else
 response.write "<BR>calling program ran ok<BR>"
End If
%>

In called.asp, paste this code...

<%
response.write "<BR>Written by the program invoked by sever.execute <BR>"
%>

Run calling.asp, and you'll see the response written by called.asp

Now change the file name used in calling.asp's server.execute statement  to something else that doesn't exist - e.g. xxx.asp and rerun calling.asp.

You'll get a page load error for calling.asp.

In calling.asp you have commented out On Error Resume next...

Change line 1 from

'On Error Resume Next

To

On Error Resume Next



Posted By: Semikolon
Date Posted: 02 May 2004 at 5:59pm
why did you comment On Error?

if it was a typo, what server are you running?


Posted By: dpyers
Date Posted: 02 May 2004 at 6:02pm

<STUPID action='smacks head on forehead'>

Doh! you're right. no wonder it didn't work.

</STUPID>



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Semikolon
Date Posted: 02 May 2004 at 6:03pm
Originally posted by dpyers dpyers wrote:

<STUPID action='smacks head on forehead'>

Doh! you're right. no wonder it didn't work.

</STUPID>




hehe LOL

that's OK dp.. everybody does mistakes..


Posted By: Coco Brown
Date Posted: 03 May 2004 at 1:26pm

On Error Resume Next

<write your code>

On Error Goto 0    <<important because this turns error back on!

if you do not remember this, than the code will happily go on ignoring errors after the section you want to error handle.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net