I have the security component in one of my comment submit forms..
Now, when something goes wrong, and the blackhole callback is called, I want to throw an InternalErrorException with a custom message, such as:
throw new InternalErrorException('You have tried to submit a comment whose security token is either invalid or expired. Please try again by reloading the blog post and commenting again. Thank you.');
The thing is that the message does not get displayed in production mode (debug == 0). What do I have to do to show the message to the user instead of “An Internal Error Has Occurred”?
This is my error500.ctp: http://pastebin.com/t9NuzuqS
What you can probably do is overwrite the
blackHoleaction of theSecuritycomponent.Currently you can find it in
cakephp\lib\Cake\Controller\Component\SecurityComponent. You should create aSecurityComponentin yourController\Componentfolder and overwrite this method as you wish:You can throw the same exception with another message.
This exceptions will be seen for users even with
debugset to 0 as detailed on the documentation