Zum Inhalt springen

Broad Exception Catch (ARCH7153)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key php.logging.catch-generic-throwable · Severity info · Category logging

Catching the most general exception type (\Throwable, \Exception) masks unrelated failures alongside the expected one and hides the real problem.

<?php
try {
$user = $this->repository->find($id);
} catch (\Throwable $e) {
return null;
}
<?php
try {
$user = $this->repository->find($id);
} catch (EntityNotFoundException $e) {
return null;
}

Catch only the specific exception types you can actually handle.