mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-22 19:38:38 +00:00
fix: dont log user errors (#4660)
This commit is contained in:
parent
81ce9c9483
commit
a599f4ba83
@ -89,12 +89,12 @@ class DisplayAction implements ActionInterface
|
|||||||
$bridge->collectData();
|
$bridge->collectData();
|
||||||
$items = $bridge->getItems();
|
$items = $bridge->getItems();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
if ($e instanceof RateLimitException) {
|
if ($e instanceof ClientException) {
|
||||||
// These are internally generated by bridges
|
$this->logger->debug(sprintf('Exception in DisplayAction(%s): %s', $bridge->getShortName(), create_sane_exception_message($e)));
|
||||||
$this->logger->info(sprintf('RateLimitException 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);
|
return new Response(render(__DIR__ . '/../templates/exception.html.php', ['e' => $e]), 429);
|
||||||
}
|
} elseif ($e instanceof HttpException) {
|
||||||
if ($e instanceof HttpException) {
|
|
||||||
if (in_array($e->getCode(), [429, 503])) {
|
if (in_array($e->getCode(), [429, 503])) {
|
||||||
// Log with debug, immediately reproduce and return
|
// Log with debug, immediately reproduce and return
|
||||||
$this->logger->debug(sprintf('Exception in DisplayAction(%s): %s', $bridge->getShortName(), create_sane_exception_message($e)));
|
$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)
|
// Some other status code which we let fail normally (but don't log it)
|
||||||
} else {
|
} else {
|
||||||
// Log error if it's not an HttpException
|
|
||||||
$this->logger->error(sprintf('Exception in DisplayAction(%s)', $bridge->getShortName()), ['e' => $e]);
|
$this->logger->error(sprintf('Exception in DisplayAction(%s)', $bridge->getShortName()), ['e' => $e]);
|
||||||
}
|
}
|
||||||
$errorOutput = Configuration::getConfig('error', 'output');
|
$errorOutput = Configuration::getConfig('error', 'output');
|
||||||
|
@ -242,9 +242,16 @@ function create_random_string(int $bytes = 16): string
|
|||||||
return bin2hex(openssl_random_pseudo_bytes($bytes));
|
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 = '')
|
function throwClientException(string $message = '')
|
||||||
{
|
{
|
||||||
throw new \Exception($message, 400);
|
throw new ClientException($message, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
function throwServerException(string $message = '')
|
function throwServerException(string $message = '')
|
||||||
|
Loading…
Reference in New Issue
Block a user