Error[$errno]: $errstr in $errfile at line $errline"); }); set_exception_handler(function($exception) use (&$callback) { error_log("Uncaught Exception: $exception\n"); self::oof($callback, "Uncaught Exception: {$exception}"); }); } private static function oof(callable $callback, string $error_message) { ob_end_clean(); http_response_code(500); header_remove(); $callback($error_message); die(); } }