In the Zend Framework library, the current practice (around 1.10.8) is that library components throw exceptions that extend Zend_Exception .
eg. the Zend_Layout component throws a Zend_Layout_Exception
In my own ZF library, where I add my own ZF components or extend existing components, I throw a Mylibrary_Exception (this is not really called that :)
I see that they will change some of them in ZF 2.0
http://framework.zend.com/wiki/display/ZFDEV2/Proposal+for+Exceptions+in+ZF2
My actual question is this:
In my MVC application in my controllers / models / views, if I need to throw an exception (and this will be rare, because obviously I will handle the expected errors differently) - BUT if I really need to throw an exception here, which is best practice in zf?
should i just
throw new Exception("this is an exception");
or should I create exception classes in my ZF modules, similar to how the ZF library is organized. that is, they have exception classes for each library component, should I have exception classes for each application module?
applications / modules / user / controllers / UserController.php
applications / modules / user / form / UserForm.php
application / modules / user / model / User.php
applications / modules / user / view / scripts / index.phtml
application / modules / user / exceptions / Exception.php (class User_Exception)
application / modules / user / exceptions / SuperexampleException.php (class User_Exception_Superexample)
I have never seen anyone do something like this before in ZF, so I'm not sure if this is a good idea.
UPDATE
To clarify my question further - when creating exceptions in the part of the MVC application (as opposed to a library) - are there any conventions regarding the use of specific exception classes (for example, a library), but only using the general class Exception?