Skip to content

Add general error handler instead of relying on browser handling #402

Description

@guidol-ive

When Hypha fails to start, the current master release only return HTTP status 500. It is left to the browser to render the page.

It is handier to (when in debug mode) to print the error and provide a more meaningful error screen. This can be accomplished by extending index.php:

try
{

before session_start() and:

}
catch (Throwable $e)
{
    http_response_code(500);
    error_log((string)$e);

    echo '<h1>Hypha down</h1>';
    echo '<p>The requested page can not be loaded.</p>';
    echo '<p>Path: ' . $_SERVER['PHP_SELF'] ?? '' . '</p>';
    echo '<p>IP Address: ' . $_SERVER['HTTP_X_FORWARDED_FOR'] ?? '' . '</p>';
    echo '<p>User Agent: ' . $_SERVER['HTTP_USER_AGENT'] ?? '' . '</p>';
    echo '<p>Error: <pre>' . $e . '</pre></p>';
}

after exit;.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions