0
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-22 03:18:36 +00:00

fix: dont log user errors (#4660)

This commit is contained in:
Dag 2025-08-08 02:16:43 +02:00 committed by GitHub
parent 81ce9c9483
commit a599f4ba83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View File

@ -89,12 +89,12 @@ class DisplayAction implements ActionInterface
$bridge->collectData();
$items = $bridge->getItems();
} catch (\Throwable $e) {
if ($e instanceof RateLimitException) {
// These are internally generated by bridges
$this->logger->info(sprintf('RateLimitException in DisplayAction(%s): %s', $bridge->getShortName(), create_sane_exception_message($e)));
if ($e instanceof ClientException) {
$this->logger->debug(sprintf('Exception in DisplayAction(%s): %s', $bridge->getShortName(), create_sane_exception_message($e)));
} elseif ($e instanceof RateLimitException) {
$this->logger->debug(sprintf('Exception in DisplayAction(%s): %s', $bridge->getShortName(), create_sane_exception_message($e)));
return new Response(render(__DIR__ . '/../templates/exception.html.php', ['e' => $e]), 429);
}
if ($e instanceof HttpException) {
} elseif ($e instanceof HttpException) {
if (in_array($e->getCode(), [429, 503])) {
// Log with debug, immediately reproduce and return
$this->logger->debug(sprintf('Exception in DisplayAction(%s): %s', $bridge->getShortName(), create_sane_exception_message($e)));
@ -102,7 +102,6 @@ class DisplayAction implements ActionInterface
}
// Some other status code which we let fail normally (but don't log it)
} else {
// Log error if it's not an HttpException
$this->logger->error(sprintf('Exception in DisplayAction(%s)', $bridge->getShortName()), ['e' => $e]);
}
$errorOutput = Configuration::getConfig('error', 'output');

View File

@ -242,9 +242,16 @@ function create_random_string(int $bytes = 16): string
return bin2hex(openssl_random_pseudo_bytes($bytes));
}
/**
* Thrown by bridges to indicate user failure. Will not be logged.
*/
final class ClientException extends \Exception
{
}
function throwClientException(string $message = '')
{
throw new \Exception($message, 400);
throw new ClientException($message, 400);
}
function throwServerException(string $message = '')