class %CSP.Error
extends %CSP.Page
This is the default CSP error page. When writing any error pages you should make this your superclass.
If an error occurs while running a hyperevent then the response is controled from the HyperEventError.
If it is an error on a standard page then you writing normal HTML output.
This error information is designed to make debugging an application easier, if you deploy a CSP application
then you should define your own error page that logs the information needed on the server and displays an
error message suitable for an end user rather than providing them with a lot of debug information.
Two particularly interesting errors are the session timeout and the decryption failure errors are both
of these can be the result of attempting to go to a page when the users session has timed out or been ended.
Commonly you would redirect them to the login page so they can re-enter the application for example in OnPreHTTP
method you can write:
New errorcode
Set errorcode=%request.Get("Error:ErrorNumber")
If errorcode=$$$CSPSessionTimeout!(errorcode=$$$InvalidDecrypt) Do Quit 1
. Set %response.Redirect="/application/login.csp"
When an error occurs several variables are set in the %request object because these may be overwritten in
generating the error page itself. These variables are all prefixed by 'Error:' and the list is:
- Error:ErrorCode - The %Status code for this error
- Error:ErrorNumber - The error number assocaited with the ErrorCode
- Error:Namespace - The namespace the page was running in when the error occurred
- Error:URL - The URL of the page in which the error occurred.
- Error:PageName - The name of the page in which the error occurred.
- Error:ResponseContentType - The %response.ContentType at the time of the error.
- Error:ResponseStatus - The %response.Status at the time of the error.
The error page will automatically set the %response.Status for some of the standard errors, such as
not being able to find the CSP page . If you wish to override this setting do so in the OnPreHTTP
method.
parameter LICENSEERRORPAGE;
If the user with a new session goes to a page and CSP is unable to allocate a license we can not run the normal
error page as this requires a license. The default behavior is to report a 'HTTP/1.1 404 Page not found' HTTP
response as this does not require a license. You may change
this by setting the class parameter LICENSEERRORPAGE on the error page for this CSP application (or the default
error page in the case of the application not found error). The values are:
- "" - Return the 404 Page not found error (this is the default)
- Path to a static HTML page - Will display this static page, for example '/csp/samples/static.html' will use the
stream server to serve up this static file. This does not require a license, but it will only work with static content.
parameter OTHERSTATICERRORPAGE;
If the user with a new session goes to a page that causes an error before a license is obtained then in order to
display the standard error page to report this error CSP would take out a license. To avoid this license use in
this case the default behavior is to report a 'HTTP/1.1 404 Page not found' HTTP response. This does not require
a license. You may change
this by setting the class parameter OTHERSTATICERRORPAGE on the error page for this CSP application (or the default
error page in the case of the application not found error). The values are:
- "" - Return the 404 Page not found error (this is the default)
- 1 - Will obtain a license and display the standard error page.
- Path to a static HTML page - Will display this static page, for example '/csp/samples/static.html' will use the
stream server to serve up this static file. This does not require a license, but it will only work with static content.
parameter PAGENOTFOUNDERRORPAGE;
If the user with a new session goes to a page that is not present then in order to display the standard error page
to report this error CSP would take out a license. To avoid this license use if the error is because the application
is not found, or the page is not found, or the class does not exist, or the page is private and the token is not
correct then the default behavior is to report a 'HTTP/1.1 404 Page not found' HTTP response. This does not require
a license and it is standard behavior if you goto a page that is not present on a normal web server. You may change
this by setting the class parameter PAGENOTFOUNDERRORPAGE on the error page for this CSP application (or the default
error page in the case of the application not found error). The values are:
- "" - Return the 404 Page not found error (this is the default)
- 1 - Will obtain a license and display the standard error page.
- Path to a static HTML page - Will display this static page, for example '/csp/samples/static.html' will use the
stream server to serve up this static file. This does not require a license, but it will only work with static content.
parameter PRIVATE = 1;
Error pages should be private to avoid the chance the user can go to them
directly by just typing in the address.
classmethod DecomposeError(sc As %Status, ByRef ErrorInfo As %String)
as %Status
Return an array of information in ErrorInfo about the error suitable for display with a
bit of formatting. You pass in the sc which is the status code of the error. It assumes
you are dealing with CSP related errors.
classmethod DisplayError(ByRef ErrorInfo As %String)
as %Status
Output in HTML the error information in ErrorInfo which is the array provided by
DecomposeError.
classmethod HyperEventError()
If an error occurs while processing a HyperEvent then this method is called.
This method will write out javascript code that will be executed on the browser.
Note that the variable 'CSPPage' refers to the 'self' of the page on which the
Hyperevent was called as this may be different to the current 'self'.
You could use this javascript to redirect the browser to another page:
Write "CSPPage.window.location='/csp/samples/menu.csp';",!
Or you could popup an alert box with the error message in it:
Write "alert('An error occurred');",!
classmethod OnErrorSetup(ByRef skipheader As %Boolean)
as %Boolean
This is called before the OnPreHTTP and will handle the HyperEvent errors and
setup the status line in the response for the standard errors.
classmethod OnPage()
as %Status
Output the error page as HTML. This makes use of the ##class(%CSP.Utils).DisplayAllObjects()
call to display as much information as possible about the state of the %request, %response, %server
objects when the error occurred.