aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind2015-03-27 14:21:34 +0100
committerMaZderMind2015-03-31 08:19:08 +0200
commit1a050c087e8f2889b421992350c50fae75a9252b (patch)
tree16cebecacf7063925c1c6e815ed8c3e2927fc829
parentf98d93cd1559d48e76366950c51e5a6a1f7a84dc (diff)
error handling
-rw-r--r--assets/css/_structure.less13
-rw-r--r--index.php7
-rw-r--r--lib/Exceptions.php8
-rw-r--r--template/500.phtml8
-rw-r--r--view/500.php10
5 files changed, 42 insertions, 4 deletions
diff --git a/assets/css/_structure.less b/assets/css/_structure.less
index 836de2b..5de12e0 100644
--- a/assets/css/_structure.less
+++ b/assets/css/_structure.less
@@ -89,7 +89,8 @@ body.relive-player {
@import "_relive_player.less";
}
-body.e404 {
+body.e404,
+body.e500 {
> .container {
text-align: center;
h1 {
@@ -104,6 +105,16 @@ body.e404 {
}
}
+body.e500 {
+ pre {
+ text-align: left;
+ }
+
+ img {
+ .rotate(180deg);
+ }
+}
+
body.feedback {
.feedback-thankyou {
font-size: @jumbo-font-size;
diff --git a/index.php b/index.php
index a00efc3..b4c87ad 100644
--- a/index.php
+++ b/index.php
@@ -32,8 +32,8 @@ $tpl->set(array(
));
+ob_start();
try {
-
if($route == '')
{
include('view/overview.php');
@@ -135,10 +135,11 @@ try {
}
catch(NotFoundException $e)
{
+ ob_clean();
include('view/404.php');
}
catch(Exception $e)
{
- header("HTTP/1.1 500 Internal Server Error");
- die($e);
+ ob_clean();
+ include('view/500.php');
}
diff --git a/lib/Exceptions.php b/lib/Exceptions.php
index f6f9d24..acdb1b6 100644
--- a/lib/Exceptions.php
+++ b/lib/Exceptions.php
@@ -1,4 +1,12 @@
<?php
+function exception_error_handler($errno, $errstr, $errfile, $errline ) {
+ if (ini_get('error_reporting') == 0)
+ return;
+
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+}
+set_error_handler("exception_error_handler");
+
class NotFoundException extends Exception {}
class ScheduleException extends Exception {}
diff --git a/template/500.phtml b/template/500.phtml
new file mode 100644
index 0000000..feee78f
--- /dev/null
+++ b/template/500.phtml
@@ -0,0 +1,8 @@
+<div class="container">
+ <h1>500 Internal Winkekatze Error</h1>
+ <div class="well">
+ <pre><?=h($e)?></pre>
+ </div>
+
+ <img src="assets/img/missing-cat.png" alt="500 Internal Winkekatze Error" />
+</div>
diff --git a/view/500.php b/view/500.php
new file mode 100644
index 0000000..6519160
--- /dev/null
+++ b/view/500.php
@@ -0,0 +1,10 @@
+<?php
+
+header("HTTP/1.1 500 Internal Server Error");
+echo $tpl->render(array(
+ 'page' => '500',
+ 'title' => '500 Internal Server Error',
+
+ 'e' => $e,
+ 'msg' => $e->getMessage(),
+));