0
问题是不允许应用程序抛出异常,并且不要在不关键的元素中停止应用程序(像用户搜索保存到DB的日志历史记录那样耗用)是更好的使用此代码:PHP Try and Catch or @
try {
/* some code here that will throw an exception at any error/miss-configuration because it is the
way this module works */
$user = Sentry::getUser();
} catch (Exception $e) {}
或:
@$user = Sentry::getUser();
这只是一个理论上的代码,但实际上哨兵是一个很好的例子来说明我的意思。在这种情况下,如果用户没有登录,Sentry会抛出异常。
正如我所说的,它只是对应用程序不重要的代码,我不会过度使用。
显然,更好的方法是编写代码来防止这种情况。 但有时需要stfu系统:)