【问题标题】:How do I configure php/apache2 to display exceptions but not stack traces?如何配置 php/apache2 以显示异常但不显示堆栈跟踪?
【发布时间】:2013-03-20 17:26:05
【问题描述】:

显示异常但不显示完整堆栈跟踪需要什么错误报告组合?

即:

throw new Exception("This is an exception");

显示“这是一个例外”,但不显示后面的完整跟踪?

【问题讨论】:

  • 你需要抓住它并只显示你想要的e.getMessage()

标签: php exception configuration apache2


【解决方案1】:

使用set_exception_handler 创建您自己的异常处理程序,它只显示错误消息

例如:

set_exception_handler(
    function($e) {
        echo $e->getMessage();
        //exit(); dont have to be called
    }
);

【讨论】:

    猜你喜欢
    • 2014-01-24
    • 1970-01-01
    • 1970-01-01
    • 2010-10-16
    • 2017-08-09
    • 2016-01-11
    相关资源
    最近更新 更多