page: return 500 status and page on php exceptions
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 13 Sep 2017 15:16:03 +0000 (17:16 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Sep 2017 18:21:28 +0000 (20:21 +0200)
Significantly catch syntax errors in editor saves.

500.php [new file with mode: 0644]
page.php

diff --git a/500.php b/500.php
new file mode 100644 (file)
index 0000000..a3e261c
--- /dev/null
+++ b/500.php
@@ -0,0 +1,8 @@
+<?php
+http_response_code(500);
+?>
+<h2>Scriptfout</h2>
+
+<p>Er ging iets mis: <pre class="warn"><?php print $error; ?></pre>
+Waarschijnlijk wordt hier aan gewerkt, maar als het probleem aanhoudt
+geef het dan aan <a href="/contact">ons</a> door.
index f6c2346e17edbfa31ac7c654c3b603425e8675f6..9acacc2a949a87cf39e23079615ecb71d8125e66 100644 (file)
--- a/page.php
+++ b/page.php
@@ -2,6 +2,11 @@
 error_reporting(E_ALL);
 ini_set('display_errors', TRUE);
 
+set_exception_handler(function ($error) {
+       include_once 'page.inc.php';
+       include_once '500.php';
+});
+
 include_once 'auth.inc.php';
 $Edit = isset($_GET['edit']);