Zum Inhalt springen

Generic Exception Thrown (ARCH7167)

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

Key php.logging.throw-generic-exception · Severity info · Category logging

Throwing the base/generic \Exception instead of a specific domain exception forces callers into broad, non-selective catch blocks.

<?php
public function withdraw(int $amount): void
{
if ($amount > $this->balance) {
throw new \Exception('Insufficient funds');
}
}
<?php
public function withdraw(int $amount): void
{
if ($amount > $this->balance) {
throw new InsufficientFundsException('Insufficient funds');
}
}

Throw a specific, domain-specific exception type so callers can catch selectively.