I'd like to create a new exception, called SecurityException. Where should I put the code?
class SecurityException extends CakeException {};
Thanks!
Create an exceptions.php file, put it on the Lib
folder and fill it up with all your *Exception
classes. Then include it on your application's bootstrap file.
require APP . 'Lib' . DS . 'exceptions.php';
All exceptions will become available application wide.
I followed luchomolina's 2nd answer (commented on his own answer), and thought it deserved to be an official answer:
Here's another approach: "put exceptions in ([plugin-if-any])/Lib/Error/Exception/NameOfTheException.php and use App::uses('NameOfTheException', 'Error/Exception') where they're needed. Seemed like a Cake'ish way to do it, and they're not included unless one is actually thrown." –luchomolina
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With