mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 20:27:31 +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);
|
$str = $this->formatException($e);
|
||||||
|
|
||||||
if (($previous = $e->getPrevious()) instanceof \Throwable) {
|
$previous = $e->getPrevious();
|
||||||
do {
|
while ($previous instanceof \Throwable) {
|
||||||
$depth++;
|
$depth++;
|
||||||
if ($depth > $this->maxNormalizeDepth) {
|
if ($depth > $this->maxNormalizeDepth) {
|
||||||
$str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
$str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str .= "\n[previous exception] " . $this->formatException($previous);
|
$str .= "\n[previous exception] " . $this->formatException($previous);
|
||||||
} while ($previous = $previous->getPrevious());
|
$previous = $previous->getPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
|
@@ -37,9 +37,10 @@ final class Util
|
|||||||
* @param CurlHandle $ch curl handler
|
* @param CurlHandle $ch curl handler
|
||||||
* @return bool|string @see curl_exec
|
* @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);
|
$curlResponse = curl_exec($ch);
|
||||||
if ($curlResponse === false) {
|
if ($curlResponse === false) {
|
||||||
$curlErrno = curl_errno($ch);
|
$curlErrno = curl_errno($ch);
|
||||||
@@ -53,7 +54,6 @@ final class Util
|
|||||||
|
|
||||||
throw new \RuntimeException(sprintf('Curl error (code %d): %s', $curlErrno, $curlError));
|
throw new \RuntimeException(sprintf('Curl error (code %d): %s', $curlErrno, $curlError));
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,6 @@ final class Util
|
|||||||
|
|
||||||
return $curlResponse;
|
return $curlResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user