Throw From Finally (ARCH7155)
هذا المحتوى غير متوفر بلغتك بعد.
Key php.logging.throw-in-finally · Severity error · Category logging
Throwing inside a finally block masks any in-flight exception from the try body, causing the real failure to be lost.
Incorrect
Section titled “Incorrect”<?phptry { $this->process($data);} finally { if (!$this->stream->close()) { throw new \RuntimeException('Close failed'); }}Correct
Section titled “Correct”<?phptry { $this->process($data);} finally { if (!$this->stream->close()) { $this->logger->warning('Stream close failed'); }}Log the error inside finally instead of throwing; let the original exception propagate.