2 # custom error handling for MinimEdit
4 function abort($body, $status = NULL)
6 if ($status) header("HTTP/1.1 $status");
14 http_response_code(500);
16 require_once('article.inc.php');
17 $Page = new ArchiveArticle(NULL);
18 $Page->title = 'Fout';
20 include_once 'page.inc.php';
23 require '500.inc.html';
24 $Page->place['debug'] = htmlspecialchars($error);
25 $Page->raw = ob_get_clean();
26 print $Page->render();
29 set_exception_handler('fail');
31 define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
33 set_error_handler(function ($level, $error, $file, $line) {
34 if ($level & E_FATAL) {
41 register_shutdown_function(function () {
42 # display failure page for fatal exceptions
43 $error = error_get_last();
44 if (!($error['type'] & E_FATAL)) return;
45 fail("Fatal: $error[message] in $error[file]:$error[line]");
48 error_reporting(error_reporting() & ~E_FATAL);