{INCLUDE _BAS_HDR.HTM}

9.  Exiting with an HTTP Error

There are several possible ways that you may wish to process a page and exit with an HTTP error.  In general, you should consider processing the following errors: It may be possible to resond with other errors, but doing so requires knowledge of HTTP and has not been tested at Modular Software.
With all of these errors, there are two possible display options:

You want a simple text on-screen message.

If you want a simple text on-screen message, you include that message in the R.ERR variable by placing the text after a semicolon and then execute a RETURN statement to exit the page before RESX is set.  This typically looks like:

You want a formatted on-screen message.

If you want a formatted on-screen message, you build that message in RESX and set the R.ERR variable to the simple HTTP error code. You can build RESX either by having the HTML page itself process, or you can use another page's HTML code by calling the web process recursively.
To use the HTML page's contents directly you would include: To use another page's HTML code, you would include code such as:

200 OK

This is the standard exit code.  To process a page with this result, you simply write embedded MV/Basic code that exits at the bottom. The web server will automatically use the 200 OK error status.

302 FOUND

This is an exit that you use if you wish to refer the use to another web location.  Most modern web browsers will automatically take the user to the new location.  For the sake of older browsers, you should also include page content that specifies a manual link to the new page location:

If you wish to return a 302 FOUND error code, you will also need to include the HTTP header fields required so that the browser will automatically follow the link forward.  You do this by including the following lines in your BASIC code:

404 NOT FOUND

This is the exit code that you use if the page being references is not present.

500 INTERNAL ERROR

This is the exit code that you use if some application error has occurred. You can be as explicit with the error text as you desire.
{INCLUDE _BAS_FTR.HTM}