- require_once './500.html';
- print str_replace('[[debug]]', $error, ob_get_clean());
+ require '500.inc.html';
+ $Page->place['debug'] = htmlspecialchars($error);
+ $Page->raw = ob_get_clean();
+ print $Page->render();
+}
+
+set_exception_handler('fail');
+
+define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
+
+set_error_handler(function ($level, $error, $file, $line) {
+ if ($level & E_FATAL) {
+ fail($error);
+ return;
+ }
+ return FALSE;