I've been using a lot of MVC for my PHP5 projects recently, as well as using pretty much every OOP related functionality it can handle (private this, static that, etc, etc.). But I've never used exceptions other that just briefly testing them out to see how they work (no surprices, since I'm already well known with how they work in Java).
So, if I were to use them on, say, my next relatively large MVC project, in what layer should I handle the exceptions? As far as I can see there's a few possibilities:
- Catch them in database related classes (DAOs) and throw them to the Controller, then;
- catch them in the Controllers and handle printing of error messages, logging, etc, directly from there, or;
- throw them further to the View layer and handle error messages, etc, there.
Or maybe:
- Catch them in DAOs and handle the printing of error messages/logging/whatever immediately without any further throwing
What would you prefer/recommend?
EDIT: Maybe this should've been in the PHP Application Design section. Ah well..





Bookmarks