【发布时间】:2018-09-21 22:22:45
【问题描述】:
在全新的 Laravel 5.6 安装(APP_DEBUG=true 在.env 文件中)一切正常,除了这种情况:
当使用abort(500, 'test exception'); 时,它会显示“糟糕,好像出了点问题。” 页面。
当使用abort(501, 'test exception');时,会显示异常追踪页面。
我的问题是:当异常代码在 .env 文件中为 500 和 APP_DEBUG=true 时,为什么我得到 “糟糕,好像出了点问题。”?
当错误码为 500 时如何在不删除vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/500.blade.php 的情况下显示正常的异常信息/跟踪。
【问题讨论】:
-
你说的都是httpexceptions是对的。 Here's an actual solution 具有覆盖 Exception\handler.php 中的 renderHttpException 的函数。 (我删除了我的答案。)
-
要使链接的答案起作用,您必须在 handler.php 的顶部添加
use Symfony\Component\HttpKernel\Exception\HttpException;。 -
感谢ourmandave,将此作为答案发布,以便我为您接受。