CakePHP 2:新例外 [英] CakePHP 2: new exceptions
本文介绍了CakePHP 2:新例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个新的异常,称为SecurityException。
我应该在哪里放置代码?
I'd like to create a new exception, called SecurityException. Where should I put the code?
class SecurityException extends CakeException {};
谢谢!
推荐答案
创建一个exceptions.php文件,将其放在 Lib
文件夹中,并将其填满所有的 * Exception
类。然后将其包含在应用程序的引导文件中。
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。 '利比'。 DS。 'exceptions.php';
所有的异常都将在应用范围内广泛使用。
All exceptions will become available application wide.
这篇关于CakePHP 2:新例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文