Catch Without Log Or Rethrow (ARCH4165)
Key java.logging.catch-log-only · Severity info · Category logging
Logging an exception and then continuing normally without rethrowing may mean an unrecoverable error is being swallowed unintentionally. The caller never learns that the operation failed.
Incorrect
Section titled “Incorrect”public void transfer(Account from, Account to, BigDecimal amount) { try { ledger.move(from, to, amount); } catch (LedgerException e) { log.error("Transfer failed", e); }}Correct
Section titled “Correct”public void transfer(Account from, Account to, BigDecimal amount) { try { ledger.move(from, to, amount); } catch (LedgerException e) { log.error("Transfer failed", e); throw new TransferException(e); }}Rethrow in addition to logging for unrecoverable errors; if swallowing is intentional, document the reason explicitly.