Skip to main content

Handling Errors

For any web application, InterSystems IRIS® data platform provides a default error page that displays a message to the user if an application error occurs. You can instead provide your own custom error page. There are special options in the case when an error occurs and no license has been obtained (so server code cannot be run).

This page assumes you are familiar with ObjectScript error handling and error logging.

Adding a Custom Error Page

To add a custom error page:

  1. Create a subclass of %CSP.ErrorOpens in a new tab and customize its OnPage() callback method.

    In this class, you can use the %request, %response, and %session objects as usual.

    In particular, %request.Get("Error:ErrorCode") contains the error information. Use DecomposeError() to obtain a multidimensional array containing the text of the error or errors, as follows:

     Do ..DecomposeError(%request.Get("Error:ErrorCode"),.ErrorInfo)
    

    Then you can loop over the ErrorInfo variable (returned by reference) as follows:

    For i=1:1:ErrorInfo {
         if (i=1) {
              set return="<p>"_ErrorInfo(i,"Desc")_"</p>"
         } else {
              set return=return_$CHAR(13,10)_"<p>"_ErrorInfo(i,"Desc")_"</p>"
         }
     }
    

    This example builds a string to be included in the HTML, with one paragraph for each error message.

    Also see %CSP.ErrorOpens in a new tab for additional methods for pulling information out of the error.

  2. Optionally override parameters of this class to display custom pages when no license has been granted.

  3. Configure the web application to use this error class.

Handling Errors Before License Grant

If a web application does not yet have a license, and a error occurs, then InterSystems IRIS displays the standard web HTTP/1.1 404 Page Not Found error message by default.

You can change what page is displayed when errors are encountered in such cases by specifying the following parameters in your error page class:

LICENSEERRORPAGE

This parameter controls what InterSystems IRIS does when a license cannot be granted. The parameter can have either the following two values:

  • "" or null — Returns the HTTP/1.1 404 Page Not Found error (default)

  • Path to a static HTML file — Displays the named file, such as /csp/myapp/static.html.

PAGENOTFOUNDERRORPAGE

This parameter controls what InterSystems IRIS does if any of the following errors are generated:

  • License cannot be granted

  • Class does not exist

  • Method does not exist

  • Web application does not exist (set parameter on default error page)

  • CSP page does not exist

  • File does not exist

  • Namespace does not exist

  • Illegal request

  • File cannot be opened

  • Session timeout

The parameter can have either the following values:

  • "" — Return the HTTP/1.1 404 Page not found error (default)

  • 1 — Obtains a license and displays the standard error page.

  • Path to a static HTML file — Displays the named file, such as /csp/myapp/static.html.

OTHERSTATICERRORPAGE

This parameter controls what InterSystems IRIS does in the case of other errors. The parameter can have any the following values:

  • "" — Obtains a license and displays the standard error page (the default)

  • 1 — Outputs the 404 Page not found error.

  • Path to a static HTML file — Displays the named file, such as /csp/myapp/static.html.

FeedbackOpens in a new tab