如何处理Laravel QueryException并使用XAMPP显示自定义错误页面

问题描述 投票:1回答:1

我正在尝试使用XAMPP处理Laravel QueryException,让我更好地解释一下。在XAMPP中打开MySql服务时,一切正常,但是当我有意关闭它(或者说我忘了)并且尝试登录时,(显然)我收到此错误Exception:

Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] Connection refused.
 (SQL: select * from `users` where `email` = [email protected] limit 1)

例如,如何显示我的一个自定义错误页面而不是默认的Laravel QueryException?在哪里捕获异常?

即使我的应用程序不在生产模式下,我仍然想正确显示错误。

谢谢!

mysql laravel exception xampp custom-error-pages
1个回答
0
投票

全部运行命令

php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear

.env文件中,将DB_HOST127.0.0.1更改为localhost

© www.soinside.com 2019 - 2024. All rights reserved.