I have the following problem: In my symfony 2 application I have a voter called "ClientIpVoter", that checks if the client ip is blacklisted (http://symfony.com/doc/2.0/cookbook/security/voters.html). If the ip is blacklisted, the Security Component throws a AccessDeniedException.
Other parts of the Security Component also throw a AccessDeniedException, for example if the user does not have the right roles.
Now my problem is, that I want to know why the AccessDeniedException was thrown, in order to do different stuff. For example displaying a message, or (if the AccessDeniedException was thrown because of insufficient roles), redirect the user to a page where he can for example confirm his account or email.
But the AccessDeniedException does not contain any information about the origin of the authorization problem. How would you implement this?