Announcement:Materials and articles for ProductCart 5 can be found at our brand new support center.

Create an account to edit articles | See Formatting Syntax for Wiki syntax | We look forward to your contribution!

Code Debugging: How to Show Raw Errors in ProductCart

Error Trapping

ProductCart includes “error trapping” routines that - in most cases - prevent raw errors from being printed to the screen in the storefront. This is not only to show customers a friendly error, rather than a “scary” technical error, but mostly for security reasons. In fact, this is a requirement for PCI compliance, among other things.

Errors, when they occur in the storefront, are in most cases saved to the database and reports can be viewed in the Control Panel under Help > Error Information. However, when an error is saved the code saves the last recorded SQL query, among other things, which can be unrelated to the actual error that is occurring. This can be misleading for a programmer that is trying to debug the code.

Code Debugging

For code debugging, there are ways to print raw errors to the screen. In most cases, this is done as follows:

  • Storefront:
    • Comment out the first “on error resume next” statement in includes/opendb.asp
    • If you use the Recently Viewed Products Widget also comment out the first “on error resume next” statement in pc/smallRecentProducts.asp
  • Control Panel:
    • Comment out the first “on error resume next” statement in includes/opendb.asp
    • Comment out the first “on error resume next” statement in pcadmin/adminv.asp

There are cases, however, in which additional error trapping exists in the code. This is the case, for instance, in files in which “opendb.asp” is not invoked. So if you followed the instructions above and errors are still not being printed to the screen there are two additional steps.

  1. Check the specific page that you are working with and do a source code search for “on error resume next”. Comment out any “on error resume next” statements you find.
  2. If you do not find any instances of “on error resume next” you can place the following code immediately after the first instance of opendb(), or prior to the section of code you are debugging.
    On error goto 0

We have also seen instances where the using a DSN instead of a DSNLESS database connection was preventing the error from being displayed. Check which type of connection you have configured and if it is not a DSNLESS one see if you can switch to one.

If you are still having problems, open a support ticket and we'll try to help.

Once you have resolved the problem, don't forget to reinstate the error trapping.

How to "comment out" a line in ASP

The paragraphs above talk about commenting out some of the ASP code. In ASP this is done by placing a single quote (apostrophe) in front of the code to be commented out. If you do this at the beginning of a line, the entire line will be considered a comment, not actual code. If you do this in the middle of a line, the code following the single quote will be considered a comment.

For example:

  • original code
    On Error Resume Next

  • entire line commented out

    ' On Error Resume Next

  • adding a comment after “live” code

    IF myVariable="1" THEN ' This is a comment to explain what the code does

Whatever code is commented out (an entire line or a portion of it) is not parsed by the Web server when the page is processed. In other words, that portion of the code is ignored.


QR Code
QR Code Code Debugging: How to Show Raw Errors in ProductCart (generated for current page)