当我扩展一个异常类时:
CustomException extends Exception(){}
throw new CustomException("Houston we have a problem",1);错误:
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问题吗?谢谢。
发布于 2013-02-16 11:30:10
这是一个xdebug选项。在您的php.ini中,您可以使用xdebug.scream=1来禁用它,并将其设置为xdebug.scream=0
Scream覆盖了@的"shut up“操作符,所以你必须关闭它来阻止这种情况的发生。不要忘记重新启动服务器以使更改生效。
发布于 2013-02-16 11:27:19
您必须使用try-catch块来捕获异常。否则,它将报告异常未被捕获。
例如:
try {
methodThatCanThrowAnException(); // used since I don't know the method you are trying to call
}
catch (CustomException $e) {
echo $e->getMessage();
}https://stackoverflow.com/questions/14906560
复制相似问题