2013-02-16 43 views
1

擴展例外:</p> <pre><code>CustomException extends Exception(){} throw new CustomException("Houston we have a problem",1); </code></pre> <p>在錯誤:當我延伸的異常類中刪除消息 「未捕獲異常XXXX與消息」

SCREAM: Error suppression ignored for 
Uncaught exception 'CustomException' with message 'Houston we have a problem' in C:\wamp\www\index.php on line 5 
CustomException: Houston we have a problem in C:\wamp\www\index on line 5 

我想只CustomException消息:

CustomException: Houston we have a problem in C:\wamp\www\index on line 5 

這可能嗎?這是一個xdebug問題嗎? 謝謝。

+0

你忘了介紹你的[testcase](http://sscce.org)。 – 2013-02-16 03:24:03

+0

@LightnessRacesinOrbit編輯。 – 2013-02-16 03:27:11

回答

3

即一個Xdebug的選項。在你的php.ini你有xdebug.scream=1要禁用它,它設置爲xdebug.scream=0

吶喊覆蓋@「閉嘴」運營商,所以你將不得不將其關閉,以阻止這種情況發生。不要忘記重新啓動服務器以使更改生效。

+0

你走了。 :) – 2013-02-16 03:32:29

+0

我關閉了尖叫,和所有的xdebug組件,它刪除了SCREAM,但仍然報告雙重錯誤:在C:\ wamp \ www \ index.php在線的消息'休斯頓我們有一個問題'的未捕獲異常'CustomException' 5 CustomException:Houston我們在第5行的C:\ wamp \ www \ index中遇到問題 – 2013-02-16 03:36:40

+1

然後您需要關閉錯誤報告。在php.ini中設置'display_errors = off'對於運行時解決方案,您可以設置'error_reporting(0);' – Stuart 2013-02-16 03:46:35

0

你必須抓住一個try-catch塊的例外。否則,它會報告未被捕獲的異常。

例如:

try { 
    methodThatCanThrowAnException(); // used since I don't know the method you are trying to call 
} 
catch (CustomException $e) { 
    echo $e->getMessage(); 
} 
+0

也許OP不想抓到它。他們希望PHP以一種理智的方式輸出關於未捕獲的異常的消息,而不需要SCREAMing。 – 2013-02-16 03:29:10

+1

@LightnessRacesinOrbit他們詢問有關郵件未被捕獲,因此我提供瞭解決方案。那怎麼回答這個問題呢?如果他們想做別的事情,我可以提供另一個答案。 – 2013-02-16 03:31:28

+0

閱讀問題。 – 2013-02-16 03:32:11

相關問題