O.stop()
function O.stop(message, pageTitle)
function O.stop(view, templateName)
When called from within a respond() request handler, immediately stop processing the request and display a message to the user. If called from outside a request scope, raise an exception.
This function does not return.
If the first argument is a string, then:
messageshould be the message to display to the user.pageTitleis optional (default value is ‘Error’). SeepageTitlefor more information.
If the first argument is an object then:
viewshould contain values to pass to the template, as perrender().templateNameis optional, and identifies the template to render the view with. This allows a plugin to have custom, shared error pages. By default a template is used that simply displays themessageview variable, with HTML characters escaped.
Example
Simple usage
P.respond('GET', '/do/example/object', [
{pathElement:0, as:'object'}
], function(E, displayedObject) {
var otherItem = displayedObject.getOtherItem();
if(!otherItem) {
O.stop('Cannot find other item for object.');
}
...
});
Using a view
P.respond('GET', '/do/example/object', [
{pathElement:0, as:'object'}
], function(E, displayedObject) {
var otherItem = displayedObject.getOtherItem();
if(!otherItem) {
O.stop({message: 'Foo',
layout: 'std:minimal'}, 'my_error_page');
}
...
});