>On 8/10/07, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
>
> You can only trap E_USER_*, E_NOTICE, E_WARNING, E_STRICT, and the new
> E_RECOVERABLE_ERROR in an error handler; fatal, parse, and compile
> errors cannot be trapped.
>
> You typically don't want to trap stricts or notices, and you have to
> pick and choose which warnings you really need to handle.
>
> That said, I often create an error handler that checks the error type,
> and if considered severe enough, throws it as an exception. This will
> then be handled in your error handler controller.
>
Hi Matthew,
I have a problem with exception trapping in the front controller.
Let's say the controller name is dummy and action name is ne which is
a nonexistent action.
The url is invoked like this: sitename.com/dummy/ne
Some snippets from the bootstrap file are as following
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory(array(
'default' => './app/default/controllers',
'admin' => './app/admin/controllers'));
$controller->setParam('noViewRenderer', true);
$controller->returnResponse(true);
$response = $controller->dispatch(); //line X
...
line X will yield a fatal error message saying uncaught exception
along with stack trace which is good.
if the above code is altered into this one:
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory(array(
'default' => './app/default/controllers',
'admin' => './app/admin/controllers'));
$controller->setParam('noViewRenderer', true);
$controller->returnResponse(true);
try {
$response = $controller->dispatch(); //line X
if($response->isException()) {
throw new Exception;
}
... process output here
} catch (Exception $e) {
print $e->getMessage();
}
the exception is now trapped but the stack trace is not there.
my question:
what's the best practice in trapping exceptions and output the stack
trace? fatal error message and stack trace are good, but the output is
not customizable.
Regards,
Mike