2 # custom error handling for MinimEdit
4 function abort($body, string $status = NULL)
7 header("HTTP/1.1 $status");
8 if ($status[0] === '3') {
9 # redirection (body specifies target)
10 header("Location: $body");
21 http_response_code(500);
23 require_once('article.inc.php');
24 $Page = new ArchiveArticle(NULL);
25 $Page->title = 'Fout';
27 include_once 'page.inc.php';
30 require '500.inc.html';
31 $Page->place['debug'] = htmlspecialchars($error);
32 $Page->raw = ob_get_clean();
33 print $Page->render();
36 set_exception_handler('fail');
38 define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
40 set_error_handler(function ($level, $error, $file, $line) {
41 if ($level & E_FATAL) {
48 register_shutdown_function(function () {
49 # display failure page for fatal exceptions
50 $error = error_get_last();
51 if (!($error['type'] & E_FATAL)) return;
52 fail("Fatal: $error[message] in $error[file]:$error[line]");
55 error_reporting(error_reporting() & ~E_FATAL);