Web Error Pages

When a web browser makes a request to Panorama X Server, the displayed result is normally HTML generated by a procedure on the server. Sometimes, however, a problem gets in the way and no HTML is generated. For example, there could be a problem in the code, or a problem with your Panorama X account. When that happens, Panorama automatically generates a rather sparse error message for display in the browser. For a production system, you may want to display a custom page when an error occurs. On this help topic you’ll learn how to set up and specify a custom error page.

There are four possible errors that can trigger a custom error page:

- code error (CodeError.html)
- missing HTML error (EmptyHTML.html)
- low account balance (LowAccountBalance.html)
- not being logged into an account at all (NotLoggedIntoAccount.html)

To customize the error page you must provide an HTML file in this folder:

    ~/Library/Application Support/PanoramaX/Server/WebErrorTemplates/

For example, if you want to create a standard errorr response for a low balance situation, you’ll need to create an HTML file named `LowAccountBalance.html`. The name must exactly match from the list above.

    ~/Library/Application Support/PanoramaX/Server/WebErrorTemplates/LowAccountBalance.html

The LowAccountBalance.html file must contain the HTML content you want to display when this error occurs. (You can also supply plain text content, with no HTML tags.)

    <html><head><title>Server Problem</title></head>
    <body>
    <hr>
    <h2 align=center>Big Corp Server is currently unavailable.</h2>
    <hr 50%>
    <h3 align=center>Contact Web Admin at extension 3453</h3>
    <hr>
    </body></html>

If your Panorama X account balance goes to zero or negative, the template page will be displayed instead of the standard plain error message page.

### Embedding Error Specific Information into the Template Page

Some errors have additional information associated with them – the name of the procedure, the code error message, etc. These items can be embedded into your template by using the item name surrounded by « and », for examle `«procedure»` or `«error»`. The items supported by each type of error are listed below. The item name must be spelled exactly, including upper and lower case.

NotLoggedIntoAccount.html

There is no additional information available for this error.

LowAccountBalance.html

There is no additional information available for this error.

EmptyHTML.html

There are three items of additional information that can be embedded into the error template:

- «database» - the name of the database specified in the URL.
- «procedure» - the name of the procedure specified in the URL.
- «url» - the portion of the URL that is being handled by Panorama (everything after `cgi.pan?`).

Here’s an example of an EmptyHTML.html template that includes some of this information.

    <html><head><title>Server Problem</title></head>
    <body>
    <hr>
    <h2 align=center>Internal server error.</h2>
    <hr 50%>
    <h3 align=center>Internal procedure «procedure» (belonging to database «database»)
    did not generate any HTML.</h3>
    <hr>
    </body></html>

CodeError.html

There are about a half dozen items of additional information that can be embedded into the error template:

- «error» - the error message.
- «statement» - the name of the statement that caused the error.
- «parameter» - the parameter that caused the error (if any).
- «database» - the name of the database specified in the URL.
- «procedure» - the name of the procedure specified in the URL.
- «url» - the portion of the URL that is being handled by Panorama (everything after `cgi.pan?`).

Here’s an example of a CodeError.html template that includes some of this information.

    <html>
    <head></head>
    <body>
    <hr>
    <h1>Panorama Code Error</h1>
    <hr>
    <ul>
    <li>ERROR: «error»</li>
    <li>URL: «url»</li>
    <li>STATEMENT: «statement»</li>
    <li>PARAMETER: «parameter»</li>
    </ul>
    <hr>
    </body>
    </html>

Of course it’s best to avoid code errors in web publishing code if at all possible. If that’s not possible, you can trap these errors yourself using the try and catch statements. See Error Handling to learn how to use these statements. But if you miss a spot and an error slips through, the CodeError.html template allows you to control the message seen in the browser.

See Also

- cgitest -- tests a CGI procedure.
- getcookie( -- returns the value of a cookie submitted to the server.
- getcookielist( -- returns a list of cookies submitted to the server.
- info("httprequestinprogress") -- returns true if this code is running on Panorama X Server, and the server is responding to a web client request.
- info("webclientsessioninprogress") -- returns true if this code is running on Panorama X Server, and the server is responding to a web client request.
- serverrunning( -- returns true if this code is running on a Panorama server, or false if it is running in single user mode or on a client.
- serverstatus( -- returns a dictionary describing the current status of Panorama X Server.
- URL Tool Menu (Web Debugging) -- tool with popup menu to assist with debugging web procedures.
- urlfilename( -- extracts the filename from a complete url.
- urlpath( -- extracts the path from a URL.
- webhomesubfolder( -- returns the folder ID of a subfolder of the web server's home folder.
- webserverinfo( -- retrieves additional information about the web server and the current browser request.
- webtagortext( -- prepares text for display in a web page.
- webtext( -- converts a number or regular text into text encoded for display in a web browser.

History

Version | Status | Notes
10.2 | New | New in this version.