disable laravel's built in error screen [dupli

2019-02-26 16:53发布

This question already has an answer here:

I want to disable Laravel's error screen that shows the errors/exceptions with debugging information and functions trace. Mostly because I'm using Laravel as mobile API backend and those responses are harder to read on a mobile device.

Please notice that I want the errors, but not the fancy error page.

Any suggestions?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-02-26 17:11

Go to Laravel project -> app folder-> config folder -> app.php set

'debug' => false,

This will show a simple error page like Ops! Something went wrong.

Edit:

Laravel App facade provides a way to way catch the exceptions using error method as mentioned in the Laravel docs

App::error(function(Exception $exception)
{
    // handle your exception
});

You can place App::error method in the filters.php

and Laravel is using Symfony to display those pages if you want to further go down. I have not really tried to change this thing, maybe someone will come up with a better answer.

查看更多
登录 后发表回答