Hi Ralf, I donŽt think that exposing the $e->getMessage() to the user would be a good idea, because it may give the user an insight of your data structure depending on what information the exception message provides.
Instead I would redirect to an error page and echo a neutral error message that something unusual went wrong and the user shoul try again or contact the webmaster. I think that defining a global exception handler is a good idea to react on all exceptions that have not been caught manually by your application. http://uk2.php.net/set_exception_handler so you could log all uncaught exceptions to an error file. Regards, Marc > Hi, > > I am still looking for the best way how to handle exceptions and errors > within an application based on the Zend Framework. > > What I understood is that all Zend Framework components throw an > exception when a problem occured and don't return false or use > trigger_error(). So, when I extend any component I should do the same. > For example if I extend Zend_Db_Table and add a check to the insert() > method that all required fields are filled, then I should also throw an > Zend_Db_Table exception rather than returning false. Please correct me > if I am wrong here. > > So, whenever I use a Zend Framework component I should add a try-catch > block around the code that uses the component. For example: > > try { > $user->insert($data); > } catch (Zend_Db_Exception $e) { > // handle error > $error = $e->getMessage(); > } > > Now I could print out the error to the screen or do whatever. Please > correct me if this is bad practice. > > What I am not quite sure about is how to handle exceptions which occur > in the controller or dispatcher correctly. The probably need to be > catched in the bootstrap file. Should I then use my view object to print > out a basic error page or is there a better way? > > Thanks for your feedback. > > Best Regards, > > Ralf _______________________________________________________________________ Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos. Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222
