并非所有异常都在错误处理程序中捕获
Not all exceptions catched within the error handler
考虑一个带有错误处理的 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
将被处理程序捕获。
我在这里错过了什么?
这可能意味着 AuthenticationException
在 onAuthenticationSuccess
和您的关闭之间已经被捕获和处理,不是吗?
考虑一个带有错误处理的 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
将被处理程序捕获。
我在这里错过了什么?
这可能意味着 AuthenticationException
在 onAuthenticationSuccess
和您的关闭之间已经被捕获和处理,不是吗?