Solved

VBScript "On Error Resume Next"

Posted on 2004-04-28
15
56,793 Views
Last Modified: 2012-06-21
Hi.  I have a page that sends information to the back end of our system.  

If the back end is down I would like it to store the information in a database.

Is there a way to use "on error" to call a function instead of "resume next"?

What I would like is to head my page like this:

<%
on error call process()

but that doesn't seem to work.

Can someone help???

0
Comment
Question by:foreverdita
  • 4
  • 4
  • 2
  • +5
15 Comments
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10939160
Change to

<%
on error call process

Then Have this at the end of the page
<%
process:
'Code to do stuff
%>
0
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10939185
Actually Im wrong, you cant do that in ASP.
Your best bet is a custom error page.

http://www.devarticles.com/c/a/ASP/Replacing-the-Error-500-ASP-Page/
0
 
LVL 28

Expert Comment

by:sybe
ID: 10939195
about On Error Resume Next: check this out: http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20935596.html
0
 

Author Comment

by:foreverdita
ID: 10939219
I am getting this error:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/newsitedesign/requestcatalog/Processcatalog.asp, line 2

on error call process
---------^


0
 

Author Comment

by:foreverdita
ID: 10939249
OK, got that last message.  Is there, then, a way I can use the socket timeout script to call the function?  Such as:

if socket.timeout = "true" then

????

Is there something like that that would work?
0
 
LVL 11

Expert Comment

by:Slimshaneey
ID: 10939254
That was a typo on my part, meant to put Goto Process. Neither will work anyway, so its irrelevant. Error handling is primitive in ASP , not like VB really.
As I suggested, a custom 500 error page is probably the best option for dealing with errors. I use them to display an error message from a branded page, and it also emails me details of the error when they happen so I know theat there is a problem on the page...
0
 
LVL 4

Expert Comment

by:lpzCoville
ID: 10939267
Hi foreverdita,

The "On Error Resume Next" statement just enables error handling in your script; it doesn't actually call a procedure.  The way to use thi is to tuen on error handling using the "On Error Resume Next" statement, execute a statement, and the trap your errors:

<%
On Error Resume Next 'enable error handling
' do domething:
cnn.Open
'handle possible errors:
If Err.Number <> 0 Then Response.Write "Error number:" & Err.Number  ' for example

%>


you can find a detailed good reference on using error handling in vbscript here: http://www.juicystudio.com/tutorial/asp/err.asp
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 31

Expert Comment

by:alorentz
ID: 10939313
>>If the back end is down I would like it to store the information in a database.

Hmmm, if the backend is down, the database will be down won't it....because the database is the backend.  So you can't write to DB anyway....you could write to text file at best.
0
 

Author Comment

by:foreverdita
ID: 10939333
Socket.TCP error '8000ffff'

Error while processing Socket opperation: Connection refused

/newsitedesign/requestcatalog/Processcatalog.asp, line 106


Here is the error that comes up when our back end is down.  (I turned it off for demonstration).  The databases will still be up as they are seperate from the back end system.
0
 
LVL 11

Accepted Solution

by:
Slimshaneey earned 500 total points
ID: 10939387
On line 105 put this code
On error resume Next

The connect to the socket as normal

on the next line,
If err.Number <> 0 then
'Will redirect to another page if there is an issue with socket
Response.redirect "Some ErrorPage"
End if
'Reset the error handler
On Error Resume 0
0
 

Author Comment

by:foreverdita
ID: 10939492
Thanks Slimshaneey - that worked.  Much thanks!
0
 

Expert Comment

by:ThaZar
ID: 11841420
It doesn't work with me...

I have:

*default.asp
<!--#include file="errorpage.asp"--> 'to view the error descr.
<%if error<>0 then
dim errorobj
set errorobj = new CError 'from errorpage.asp
errorobj.displayerror
set errorobj = nothing
end if
%>

*newpage.asp
<!--include file="default.asp"-->
<%on error goto 0%>
<%
'here some code to generate error
%>

I do get an error message, but that standard error, and not the errorpage.asp

Howcome?

Regards
ThaZar
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11841487
ThaZar  - you cannot add onto old questions with you're own questions.  If you need assistance, then you can post a new questions to the forum, and Experts will assist you.

Thanks.
0
 

Expert Comment

by:7of9121098
ID: 12203984

<%
   On Error Resume Next
 <%
   'Your asp code...

  'Check for Errors
   If Err <> 0 Then 'An Error occurred             
       Call UpdateProcess()
   Else 'No errors,
     'Disable the On Error Resume next, sloppy coding...
     On Error Goto 0
   End If       

%>


0
 

Expert Comment

by:fyrye
ID: 22837529
Sorry for the 4 year post update but I believe this would be more useful should someone be looking.
<% @ Language="VBScript" %>

<% 

Option Explicit

On Error Resume Next

Sub ProcessErrors()

   'Optionally you can redirect to an error page or processing page

   'Response.Redirect("ErrorProcessor.asp")

    Response.Write "Error: " & Err.Number & "<br>" & Err.Description

    Response.End

End Sub

'Cause an Error

Resonse.Wite("This is not correct for a reason")

If Err.Number <> 0 AND  Then

    'Optionally you can change the Number to suite your needs

    'err.number <> 0 and err.number<>9 and err.number<>5 and err.number<>13 and err.number<>94 and err.number<>424 and err.number<>3265

    ProcessErrors()

End If

On Error GoTo 0 'Now Halt on errors

Response.Write("Hey no errors I care about were found")

%>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding items to html ul from on server side. 4 55
Grab data from remote page 10 60
Issue with Loop 4 49
Update field in order 21 120
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now