mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-30 21:30:14 +02:00
feat: improve error/exception ui (#3690)
This commit is contained in:
@@ -44,6 +44,8 @@ final class AuthenticationMiddleware
|
||||
{
|
||||
http_response_code(401);
|
||||
header('WWW-Authenticate: Basic realm="RSS-Bridge"');
|
||||
return render('access-denied.html.php');
|
||||
return render(__DIR__ . '/../templates/error.html.php', [
|
||||
'message' => 'Please authenticate in order to access this instance!',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ final class RssBridge
|
||||
set_exception_handler(function (\Throwable $e) {
|
||||
self::$logger->error('Uncaught Exception', ['e' => $e]);
|
||||
http_response_code(500);
|
||||
print render(__DIR__ . '/../templates/error.html.php', ['e' => $e]);
|
||||
print render(__DIR__ . '/../templates/exception.html.php', ['e' => $e]);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
@@ -117,7 +117,7 @@ final class RssBridge
|
||||
} catch (\Throwable $e) {
|
||||
self::$logger->error('Exception in RssBridge::main()', ['e' => $e]);
|
||||
http_response_code(500);
|
||||
print render(__DIR__ . '/../templates/error.html.php', ['e' => $e]);
|
||||
print render(__DIR__ . '/../templates/exception.html.php', ['e' => $e]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,8 +34,9 @@ function render(string $template, array $context = []): string
|
||||
}
|
||||
|
||||
/**
|
||||
* Render template as absolute path or relative to templates folder.
|
||||
* Do not pass user input in $template
|
||||
* Render php template with context
|
||||
*
|
||||
* DO NOT PASS USER INPUT IN $template or $context
|
||||
*/
|
||||
function render_template(string $template, array $context = []): string
|
||||
{
|
||||
|
@@ -115,8 +115,8 @@ final class CurlHttpClient implements HttpClient
|
||||
$attempts = 0;
|
||||
while (true) {
|
||||
$attempts++;
|
||||
$data = curl_exec($ch);
|
||||
if ($data !== false) {
|
||||
$body = curl_exec($ch);
|
||||
if ($body !== false) {
|
||||
// The network call was successful, so break out of the loop
|
||||
break;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ final class CurlHttpClient implements HttpClient
|
||||
|
||||
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||
curl_close($ch);
|
||||
return new Response($data, $statusCode, $responseHeaders);
|
||||
return new Response($body, $statusCode, $responseHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user