www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > ASP

    ASP Discussion and technical support for using and deploying Active Server Pages.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 02-10-2003, 03:40 PM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
      #2  
    Old 02-10-2003, 06:15 PM
    Ribeyed's Avatar
    Ribeyed Ribeyed is offline
    NHS Software Developer
     
    Join Date: Jan 2003
    Location: Dundee, Scotland
    Posts: 1,142
    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.
    Reply With Quote
      #3  
    Old 02-11-2003, 11:17 AM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
      #4  
    Old 02-11-2003, 11:30 AM
    Ribeyed's Avatar
    Ribeyed Ribeyed is offline
    NHS Software Developer
     
    Join Date: Jan 2003
    Location: Dundee, Scotland
    Posts: 1,142
    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.
    Reply With Quote
      #5  
    Old 02-11-2003, 12:24 PM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
      #6  
    Old 02-11-2003, 12:55 PM
    Ribeyed's Avatar
    Ribeyed Ribeyed is offline
    NHS Software Developer
     
    Join Date: Jan 2003
    Location: Dundee, Scotland
    Posts: 1,142
    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.
    Reply With Quote
      #7  
    Old 02-11-2003, 02:54 PM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
      #8  
    Old 02-11-2003, 04:39 PM
    Ribeyed's Avatar
    Ribeyed Ribeyed is offline
    NHS Software Developer
     
    Join Date: Jan 2003
    Location: Dundee, Scotland
    Posts: 1,142
    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.
    Reply With Quote
      #9  
    Old 02-11-2003, 05:52 PM
    Scriptage Scriptage is offline
    Registered User
     
    Join Date: Nov 2002
    Location: England
    Posts: 669
    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
    Reply With Quote
      #10  
    Old 02-12-2003, 03:26 PM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
      #11  
    Old 02-18-2003, 01:15 AM
    russell russell is offline
    Registered User
     
    Join Date: Feb 2003
    Posts: 2,747
    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
    Reply With Quote
      #12  
    Old 02-18-2003, 01:30 PM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
      #13  
    Old 02-18-2003, 09:25 PM
    russell russell is offline
    Registered User
     
    Join Date: Feb 2003
    Posts: 2,747
    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
    Reply With Quote
      #14  
    Old 02-19-2003, 10:09 AM
    Will192 Will192 is offline
    Registered User
     
    Join Date: Dec 2002
    Location: St. Louis
    Posts: 55
    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
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:41 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.