webCOMAND

controller::show_error()

Produce an error response, which is useful when a controller can find the requested resource, but some other error occurred.

Prototype

void show_error(string $message = '', string $filename = NULL, string $status_code = 500)

Parameters

  • message - Message to display on 500 (or other Status Code) page.  Can contain HTML.
  • filename - Path to a cMVC view that will receive the message as $message.
  • status_code - The HTTP response status codes to return with the error page.

Example

// the show controller method
public function web__show($oid=0) {
    $repo = $this->repo();
    $object = $repo->get_by_oid($oid); 
    if(!$object || $object->ContentType->Identifier!='Contact'){
        $repo = $this->show_error('OID does not reference a Contact');
    }
    echo('Found object: ' . $object->Summary());
}

Related

view::show_error(), show_404()