I have some custom exception for my application. I placed them to app where it is running well. Now I want to move them to one of my plugin and use exception from their.
I have implemented custom exception as mentioned here: http://book.cakephp.org/2.0/en/development/exceptions.html
But, I am looking for same solution if I use exception classes from cakephp plugin.
Any suggestion...???
Lets say you want to put your exceptions in Custom plugin /app/Plugin/Custom/Lib folder:
// Location: /app/Plugin/Custom/Lib/CustomException.php
<?php
class CustomException extends CakeException {};
Now you need to load Custom plugin in /app/Config/bootstrap.php:
// Location: /app/Config/bootstrap.php
CakePlugin::load('Custom');
And wherever you want to use CustomException
:
<?php
App::uses('CustomException', 'Custom.Lib');
class ApiController extends AppController {
public function demo() {
throw new CustomException("Just testing");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.