Displaying runtime errors

4GL JSP pages provide centralized error processing that reports errors occurring before page generation, such as errors generated when server events are triggered during page processing. When you display runtime errors for production pages, the messages tell your users about problems they might encounter when they view a page.

Enabling runtime error reporting

You enable the reporting of runtime errors on the Errors page of the Page Properties dialog box. You choose where the errors get displayed.

StepsTo enable reporting of runtime errors:

  1. Right-click on a 4GL JSP page open in the HTML editor, then select Page Properties from the pop-up menu.

  2. Click the Errors tab.

  3. On the Errors page, select how you want runtime errors displayed.

    You can display errors on a page, in an alert box, or in both places:

    Shown is the Errors tab page of the Page Properties dialog box. At top is a selected check box labeled Show Runtime Errors in alert message box and another labeled Show Runtime Errors as text. The second one has radio buttons lableled At the top of the page and At the bottom of the page. The first button is selected. Last is a cleared check box labeled Enable Trace.

Writing scripts to customize runtime error reporting

Another way to report runtime errors is by writing scripts that call methods and properties on the psPage object. The ReportError method triggers the ServerError event, then depending on the return value from ServerError, adds an error to the error log. The psPage object has the following properties to support error reporting:

Table 12-19: psPage properties that support error handling

Use this property

To do this

showErrorsOnPage

Generate processing errors when the page is generated

showErrorsAtTop

Display processing errors at the top or bottom of the page

showErrorsInAlert

Display processing errors in a separate alert box

To display errors elsewhere on a page, use the BeforeGenerate event to make sure the errors are available when the page generates.

The psPage object also has these methods for displaying errors:

Table 12-20: psPage methods for displaying errors

Use this method

To do this

WriteErrorsToDocument

Define a precise location where error messages are to appear on a page

TestCompError

Check whether a method on an EAServer component caused any errors

For more information about the methods and properties that support error reporting on the psPage object, see the online Web and JSP Target Reference.