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.
Incorrect
Section titled “Incorrect”<?phppublic function withdraw(int $amount): void{ if ($amount > $this->balance) { throw new \Exception('Insufficient funds'); }}Correct
Section titled “Correct”<?phppublic 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.