diff --git a/route.php b/route.php
index 15bacdc..19d1d69 100644
--- a/route.php
+++ b/route.php
@@ -562,10 +562,7 @@ class route
}
catch (Exception $e)
{
- @header ($_SERVER["SERVER_PROTOCOL"]." 500 Internal Server Error");
- // TODO : Allow a specific page to be configured and displayed
- echo "
Internal server error
";
- echo $e->getMessage();
+ $this->error ($e);
}
exit;
}
@@ -599,42 +596,7 @@ class route
}
catch (Exception $e)
{
- if ($e->getCode () === "")
- $getCode = 500;
- else
- $getCode = $e->getCode ();
-
- // If an error class/method is defined, use it in place of the default
- // one.
- // The errors must be defined in an array("class", "method");
- if ($this->errors !== null)
- {
- if (! is_array ($this->errors))
- die ("The route::\$errors is not an array\n");
- if (! isset ($this->errors[0]) || ! isset ($this->errors[1]))
- die ("The route::\$errors is not correct : must be the class and ".
- "the method in an array\n");
- $a = new $this->errors[0];
- $method = $this->errors[1];
- $a->$method ($getCode, $e->getMessage());
- exit;
- }
-
- $http = new http ();
- @header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
- $http->codetext ($getCode));
- // TODO : Allow a specific page to be configured and displayed
- echo "\n";
- echo " \n";
- echo " ".$http->codetext ($getCode)."\n";
- echo " \n";
- echo " \n";
- echo " \n";
- echo" \n";
- echo "".$http->codetext ($getCode)."
";
- echo $e->getMessage();
- echo" \n";
- echo "\n";
+ $this->error ($e);
}
exit;
}
@@ -642,4 +604,47 @@ class route
if ($this->debug)
echo "==> NO MATCH\n";
}
+
+ /** Print an error page. If a custom page exists, use it
+ @param $e Exception to print */
+ public function error ($e)
+ {
+ if ($e->getCode () === "")
+ $getCode = 500;
+ else
+ $getCode = $e->getCode ();
+
+ // If an error class/method is defined, use it in place of the default
+ // one.
+ // The errors must be defined in an array("class", "method");
+ if ($this->errors !== null)
+ {
+ if (! is_array ($this->errors))
+ die ("The route::\$errors is not an array\n");
+ if (! isset ($this->errors[0]) || ! isset ($this->errors[1]))
+ die ("The route::\$errors is not correct : must be the class and ".
+ "the method in an array\n");
+ $a = new $this->errors[0];
+ $method = $this->errors[1];
+ $a->$method ($getCode, $e->getMessage());
+ exit;
+ }
+
+ $http = new http ();
+ @header ($_SERVER["SERVER_PROTOCOL"]." $getCode ".
+ $http->codetext ($getCode));
+ // TODO : Allow a specific page to be configured and displayed
+ echo "\n";
+ echo " \n";
+ echo " ".$http->codetext ($getCode)."\n";
+ echo " \n";
+ echo " \n";
+ echo " \n";
+ echo" \n";
+ echo "".$http->codetext ($getCode)."
";
+ echo $e->getMessage();
+ echo" \n";
+ echo "\n";
+ exit;
+ }
}