CakePHP - How to create custom exceptions?

I am trying to throw a custom exception that will then be displayed in my own AppExceptionRenderer class (which I already made).

I read this CakePHP 2.x Cookbook - creating my own exceptions for applications , but it seems to have different unanswered / undocumented questions.

  • Where is the main class located CakeException? I can not find it anywhere in lib/Cake/. My exception class should extend this, but I have no idea which path should be for App::uses(). I also cannot look at the class to find out what I need to do with my class or what properties I can use from the parent class.

  • Where should I put my own exception class? I was going to put it in app/Lib/Error/Exception/because I don't have the best ideas, and the documentation says nothing about it.

Edit: did the CakeException class delete in Cake 2.4?

+4
source share
1 answer
  • All exceptions are obviously in Cake / Error / exceptions.php , including CakeException .

  • Lib / Error / Exception sounds good to me. It is not defined where you should place them, but it is the most logical place to place them.

, , . -. .

+2

Source: https://habr.com/ru/post/1529790/


All Articles