并非所有异常都在错误处理程序中捕获

时间:2016-10-21 10:28:58

标签: symfony exception silex

考虑使用错误处理的Silex应用程序:

$app->error(function (\Exception $exception, $code) use ($app, $locale) {
    die($exception->getMessage());    
});

出于登录目的,定义了AuthenticationSuccessHandler

use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;

class AuthenticationSuccessHandler extends DefaultAuthenticationSuccessHandler
{
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        ...

        if ($somethingWrong) {
            throw new AuthenticationException();
        }

        ...
    }
}

错误处理程序中没有捕获AuthenticationException

然而,处理程序会抓住\RuntimeException\Exception

我在这里缺少什么?

1 个答案:

答案 0 :(得分:1)

这可能意味着AuthenticationException已经在onAuthenticationSuccess和你的关闭之间被捕获和处理了,不是吗?