code results in a fatal error thrown up on the screen instead of
allowing me to gracefully handle it.
Below is a code example.
The variable $id is a umber for the article I am trying to pull up.
if $id is a number that there is no record for in the database then it
will crash.
try {
$this->view->mainArticle = $this->article->find($id)->current()-
>toArray();
}
catch( Exception $e )
{
Zend_Registry::get('logger')->err($e->getMessage());
Zend_Registry::get('logger')->notice('User tried to do somthing
in articles that was not allowed');
$this->_helper->redirector('index','index');
}
The error I was getting is Fatal error: Call to a member function
toArray() on a non-object in. My catch code is not ever getting a
chance to gracefully handle the problem.
I read thourgh the documentation the result is supposed to be a rowset
object even if the query fails. But the toArray() causes the fatal
error.
没有评论:
发表评论