|
|||||||
| ASP Discussion and technical support for using and deploying Active Server Pages. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
onError Help!!!
I have my error checking setup in Javascript. If I get an ASP error, the error checker doesn't catch it. What do I have to do to get error capture at the ASP level?
Will192
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
|
#2
|
||||
|
||||
|
hi,
2 ways you can do this, first remove this line: onerror resume next or add in this line: set objError = Server.GetLastError() response.write objError.Description Hope this helps
__________________
---------------------------------- ASP.NET, VB.NET, B2B Applications, .NET Framework, T-SQL, Windows 2003 Server, SQL Server, AJAX, ASP, SEO, CSS, Mobile Technologies, Bluetooth, Wi-Fi. |
|
#3
|
|||
|
|||
|
I understand taking out the one line. The other two lines don't seem to do anything that has to do with capturing the error condition. Thanks for the reply, but please explain.
Will192
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
|
#4
|
||||
|
||||
|
Hi,
<% onerror resume next set objError = Server.GetLastError() response.write objError.Description %> The GetLastError method allows you to retrieve information about the last error that occured in a script and proces it accordinaly. This method is called from within the script, which is invoked automatically when an error occurs. The GetLastError method returns an ASPError object, which contains error information: the error's number, its description, the script name, line number where it occurred, and so on. You can use the properties of the ASPError object to take some action from within your script or at least display a descriptive error message to the viewer. The objError is and ASPError object variable that exposes a number of properties with information about the last error. To find out the description of the error you use the Description property of the objError variable, ok?
__________________
---------------------------------- ASP.NET, VB.NET, B2B Applications, .NET Framework, T-SQL, Windows 2003 Server, SQL Server, AJAX, ASP, SEO, CSS, Mobile Technologies, Bluetooth, Wi-Fi. |
|
#5
|
|||
|
|||
|
I understand that the GetLastError will return the last error information.
What I need is the ASP equilivant of window.onerror statement in Javascript. I need to be able to set which procedure/function is called when an ASP error occurs. The GetLastError function will be useful in the procedure/function that is called when I get an ASP error. I just need to be able to set what function is called. Thanks again for your quick response. Will192
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
|
#6
|
||||
|
||||
|
hi,
there is another property of the ASPError objetc you can try: response.write objError.Source This would display the statement that cause the error.
__________________
---------------------------------- ASP.NET, VB.NET, B2B Applications, .NET Framework, T-SQL, Windows 2003 Server, SQL Server, AJAX, ASP, SEO, CSS, Mobile Technologies, Bluetooth, Wi-Fi. |
|
#7
|
|||
|
|||
|
Thanks for the help, but it doesn't solve my problem.
Here is what I need: I need a statement that directs my program to to another function/procedure when an error occurs. The information that you are giving me is helpful. Your suggestion only gives me information on what do to in my error handling procedure, not how to set my procedure/function to what is called when an error occurs. I need to be able to call a procedure when an error occurs. Thanks for your quick reply. Will192
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
|
#8
|
||||
|
||||
|
hi,
ok no problem can you post the code you have so far?
__________________
---------------------------------- ASP.NET, VB.NET, B2B Applications, .NET Framework, T-SQL, Windows 2003 Server, SQL Server, AJAX, ASP, SEO, CSS, Mobile Technologies, Bluetooth, Wi-Fi. |
|
#9
|
|||
|
|||
|
try this
I don't know how closely vbscript and visual basic are related but you can try this.
In visual basic when you have a sub routine you can define the code to run in an error by writing this: sub some_subroutine on Error GoTo errorHandler your code here Exit Sub errorHandler: code to run on error goes here end sub This is the best way to handle errors in vb... I can't see vbscript being much different. Regards Scriptage |
|
#10
|
|||
|
|||
|
Ok guys, here is my Javascript code. What I need to do in ASP is trap the error. I know how to pull the error information once I trap it. I just need to figure out how to trap the error in ASP.
// JavaScript Source for vperror.js // written by Will Summers function Werror(message, url, line) { err=''; for (var i = 0; i < message.length; i++) { if (message.charAt(i)!="'") { err=err+message.charAt(i); } } var newurl = 'vperror.asp?errormessage='+err+'&errorurl='+url+'&errorline='+line+'&errorSuitsID=none'+fnKey; window.location=newurl; } window.onError=Werror; In another file I have this line to setup the error checking: <SCRIPT LANGUAGE='JavaScript' SRC='vperror.js' ></SCRIPT> This method will trap HTML & Javascript errors, what I need is to trap the ASP errors. Thanks in advance for any help any of you can give. Will
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
|
#11
|
|||
|
|||
|
In ASP / VbScript
<% On Error Resume Next doSomethingThatMightRaiseAnError If err.number <> 0 Then ' We Trapped an error!!! With Response .Write Err.Number & "<br>" .Write Err.Description & "<br>" End With End If Hopefully, you can think of a more elegant way to handle the error than just write it to the screen, but there is your standard VbScript error trapping routine. -- rb |
|
#12
|
|||
|
|||
|
I'm pretty sure that this code will only trap an error on the front end.
I need ASP code that will trap an error that happens on the backend. I need to trap errors such as a misspelled table name. Thanks for the reply, I will try it out and see if it helps with backend errors. Will192
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
|
#13
|
|||
|
|||
|
That will trap errors on the back-end.
On Error Resume Next sql = "SELECT * FROM BadTableName" Set rs = cn.Execute(sql) ... If Err.Number <> 0 Then ' handle the rror end if |
|
#14
|
|||
|
|||
|
That would explain the responses that I have been getting. Thanks for clearing it up.
Will192
__________________
MY SERVER'S SETUP: Win NT 2000 Server(latest service pack) ASP/ADO/Javascript SQL Server 7.0 |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|