Skip to content

Empty Catch Block (ARCH7150)

Key php.logging.empty-catch-block · Severity error · Category logging

A catch handler with an empty body (or only comments) silently swallows the exception and hides the failure, making the bug impossible to diagnose.

<?php
try {
$this->processPayment($order);
} catch (\Throwable $e) {
// ignore
}
<?php
try {
$this->processPayment($order);
} catch (PaymentException $e) {
$this->logger->error('Payment processing failed', ['exception' => $e]);
throw $e;
}

Log the exception at minimum, or rethrow it; never swallow it silently.