Catch Without Log Or Rethrow (ARCH7165)
Esta página aún no está disponible en tu idioma.
Key php.logging.catch-log-only · Severity info · Category logging
Catching and logging an exception then continuing normally without rethrowing can be an unintended swallow for unrecoverable errors.
Incorrect
Section titled “Incorrect”<?phptry { $this->chargeCard($order);} catch (PaymentException $e) { $this->logger->error('Charge failed', ['exception' => $e]); // flow continues, order treated as paid}Correct
Section titled “Correct”<?phptry { $this->chargeCard($order);} catch (PaymentException $e) { $this->logger->error('Charge failed', ['exception' => $e]); throw $e;}Rethrow the exception after logging for unrecoverable errors.