I am trying to throw a custom exception, which then gets rendered by my custom AppExceptionRenderer class (which I've already made).

I've read this CakePHP 2.x Cookbook - Creating your own application exceptions but it seems to have various unanswered/undocumented questions.

  1. Where is the core class CakeException? I can't find this anywhere in lib/Cake/. My exception class has to extend this but I have no idea what the path needs to be for App::uses(). I also can't look at the class to see what I need to do with my class or which properties I can use from the parent class.

  2. Where am I supposed to put my custom exception class? I was going to put it in app/Lib/Error/Exception/ because I have no better ideas and the documentation doesn't say anything about this.

Edit: Has the CakeException class been removed in Cake 2.4?

有帮助吗?

解决方案

  1. All the exceptions are obviously in Cake/Error/exceptions.php including the CakeException class.

  2. Lib/Error/Exception sounds good to me. It is not really defined where you should put them but thats the most logical place to put them in.

And whenever you need to find a class try searching the codebase for the class declaration. Most easy and quick way to find something. It is trivial to find things this way.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top