我試圖調試一個失敗的PHP腳本。PHP吞嚥異常
我發現引發異常的位置,但是該進程在可以被捕獲之前退出。
我已經添加了兩個try-catch塊。周圍的代碼來自Magento。
class Varien_Image {
function __construct($fileName=null, $adapter=Varien_Image_Adapter::ADAPTER_GD2)
{
try {
$this->_getAdapter($adapter);
$this->_fileName = $fileName;
if (isset($fileName)) {
$this->open(); // throws here from a few frames deeper
}
} catch(Exception $e) {
echo "WE DO GET HERE\n";
throw $e;
}
}
//...
}
class Mage_Catalog_Model_Product_Image ... {
//...
public function getImageProcessor() {
//...
try {
echo "START\n";
$this->_processor = new Varien_Image($this->getBaseFile());
} catch(Exception $e) {
echo "BUT WE NEVER GET HERE - THE PROCESS EXITS INSTEAD\n";
}
//...
}
//...
}
輸出是
START
WE DO GET HERE
爲什麼會異常被吞噬或導致進程死嗎?
編輯
它退出時的狀態碼255
通過使用strace運行:
write(1, "WE DO GET HERE\n", 15WE DO GET HERE
) = 15
write(3, "\1\0\0\0\1", 5) = 5
shutdown(3, SHUT_RDWR) = 0
close(3) = 0
munmap(0x7f254d9f3000, 151552) = 0
close(2) = 0
close(1) = 0
munmap(0x7f254da1f000, 4096) = 0
close(0) = 0
munmap(0x7f254da20000, 4096) = 0
munmap(0x7f2548d95000, 266240) = 0
munmap(0x7f2548d54000, 266240) = 0
munmap(0x7f2548c91000, 266240) = 0
brk(0x691f000) = 0x691f000
brk(0x679f000) = 0x679f000
brk(0x641e000) = 0x641e000
brk(0x5b9e000) = 0x5b9e000
brk(0x4f5e000) = 0x4f5e000
brk(0x4dde000) = 0x4dde000
brk(0x4c5e000) = 0x4c5e000
brk(0x4ade000) = 0x4ade000
brk(0x47de000) = 0x47de000
brk(0x465e000) = 0x465e000
brk(0x439e000) = 0x439e000
brk(0x3e9e000) = 0x3e9e000
brk(0x3813000) = 0x3813000
brk(0x3693000) = 0x3693000
brk(0x3513000) = 0x3513000
brk(0x3393000) = 0x3393000
munmap(0x7f2548c50000, 266240) = 0
munmap(0x7f2548cd2000, 266240) = 0
munmap(0x7f2548d13000, 266240) = 0
munmap(0x7f2548dd6000, 266240) = 0
munmap(0x7f2549e93000, 2126744) = 0
munmap(0x7f2549c63000, 2293440) = 0
munmap(0x7f2549a3a000, 2264288) = 0
munmap(0x7f254a09b000, 2131176) = 0
munmap(0x7f254a2a4000, 2247424) = 0
munmap(0x7f254aa01000, 2151656) = 0
munmap(0x7f254a4c9000, 5471824) = 0
munmap(0x7f254ac0f000, 2164040) = 0
munmap(0x7f254ae20000, 2209936) = 0
munmap(0x7f254b03c000, 2267912) = 0
brk(0x2c3a000) = 0x2c3a000
munmap(0x7f254d89e000, 1052672) = 0
munmap(0x7f254d99f000, 266240) = 0
munmap(0x7f254d84f000, 323584) = 0
exit_group(255) = ?
+++ exited with 255 +++
它立即呼應 '我們得到HERE',然後開始關機。 fd 3上的SHUTDOWN是數據庫的套接字。
感謝您的回答。我不認爲就是這樣。我確實有你所建議的error_reporting設置。缺少的分號是編寫問題時出現的錯誤。我會解決這個問題。 – Joel
在'Varien_Image'邏輯的某個地方是否有任何'die;'命令? –
沒有。除非我丟失了某些東西,否則在throw之後運行的下一行應該是echo語句。 – Joel