mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 09:50:26 +02:00
Updating while loops to have boolean conditions. (#1956)
* Updating while loops to have boolean conditions. * Refactor exception normalization logic in LineFormatter for improved readability and efficiency * Update retry logic in Curl Util to use retry count . * Skip the if now that we check before starting the loop --------- Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
This commit is contained in:
@@ -204,16 +204,15 @@ class LineFormatter extends NormalizerFormatter
|
||||
{
|
||||
$str = $this->formatException($e);
|
||||
|
||||
if (($previous = $e->getPrevious()) instanceof \Throwable) {
|
||||
do {
|
||||
$depth++;
|
||||
if ($depth > $this->maxNormalizeDepth) {
|
||||
$str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||
break;
|
||||
}
|
||||
|
||||
$str .= "\n[previous exception] " . $this->formatException($previous);
|
||||
} while ($previous = $previous->getPrevious());
|
||||
$previous = $e->getPrevious();
|
||||
while ($previous instanceof \Throwable) {
|
||||
$depth++;
|
||||
if ($depth > $this->maxNormalizeDepth) {
|
||||
$str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||
break;
|
||||
}
|
||||
$str .= "\n[previous exception] " . $this->formatException($previous);
|
||||
$previous = $previous->getPrevious();
|
||||
}
|
||||
|
||||
return $str;
|
||||
|
@@ -37,9 +37,10 @@ final class Util
|
||||
* @param CurlHandle $ch curl handler
|
||||
* @return bool|string @see curl_exec
|
||||
*/
|
||||
public static function execute(CurlHandle $ch, int $retries = 5, bool $closeAfterDone = true)
|
||||
public static function execute(CurlHandle $ch, int $retries = 5, bool $closeAfterDone = true): bool|string
|
||||
{
|
||||
while ($retries--) {
|
||||
while ($retries > 0) {
|
||||
$retries--;
|
||||
$curlResponse = curl_exec($ch);
|
||||
if ($curlResponse === false) {
|
||||
$curlErrno = curl_errno($ch);
|
||||
@@ -53,7 +54,6 @@ final class Util
|
||||
|
||||
throw new \RuntimeException(sprintf('Curl error (code %d): %s', $curlErrno, $curlError));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ final class Util
|
||||
|
||||
return $curlResponse;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user