diff --git a/route.php b/route.php index 0e39720..2b35f6d 100644 --- a/route.php +++ b/route.php @@ -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 "\n"; echo " \n";