route : Add support to errors from the application

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1820 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-09-16 11:34:37 +00:00
parent 75910359d9
commit 3cd475a0d9

View File

@@ -21,6 +21,10 @@ class route
public $debug=0;
//public $defaultOutput = "html"; // Default renderer : html
// Provide the static class::method to errors in routing.
// Must be provided in an array(class,method);
public $errors = null;
/** Return the baseURL of the site
Always finish with a slash
@param string|null $module The module name (if thereis one) */
@@ -600,8 +604,19 @@ class route
else
$getCode = $e->getCode ();
// If an error class/method is defined, use it in place of the default
// one.
// The error method must be a "static public function"
// The errors must be defined in an array ("class", "method");
if ($this->errors !== null)
{
forward_static_call($this->errors, $getCode, $e->getMessage());
exit;
}
$http = new http ();
@header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".$http->codetext ($getCode));
@header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
$http->codetext ($getCode));
// TODO : Allow a specific page to be configured and displayed
echo "<html>\n";
echo " <head>\n";