Our blog
Zend Framework More Detailed Stack Trace
If like me you kicked off your Zend Framework experience with the Quick Start and have kept the error controller system of the Quick Start for your other ZF projects, you might find this little snippet useful.
The Quick Start uses the Exception::getTraceAsString() method to give you the stack trace. Unfortunately this function seems to snip off a bit of useful info.. almost tantalising you with the info but not quite giving you enough to actually know what is going wrong!
To get a more detailed stack trace, I recommend changing this and using the Exception::getTrace() function which returns and array of the trace. You can then echo out all of this info in full.
For me (as I have xdebug for my dev environment, which is the only place you should be dumping stack traces anyway) I use the following chunk of code in my views/scripts/error/error.phtml
-
<? // application/views/scripts/error/error.phtml ?>
-
-
<h1>An error occurred</h1>
-
<h2><?= $this->message ?></h2>
-
-
<? if ('production' != $this->env): ?>
-
<h3>Exception information:</h3>
-
<p>
-
<b>Message:</b> <?= $this->exception->getMessage() ?>
-
</p>
-
<h3>Request Parameters:</h3>
-
-
<h3>Stack Trace 2:</h3>
-
<?php
-
foreach($this->exception->getTrace() as $t){
-
}
-
?>
-
<? endif ?>
More Reading:
3 Comments
|
[...] I experimented with echoing out each trace as detailed in this post, however I found that this caused a fatal error due to some kind of recursion so I have commented [...] |
|
I agree that the default stack trace is quite confusing Where do I change the Exception stack trace thing to make it use the view script you have made? thanks in advance |
|
if you used the quick start as the basis of your zend framework project layout, you should find this file: application/views/scripts/error/error.phtml |
RSS Feed
Magento More Detailed Exception Log | Edmonds Commerce Blog
June 10th, 2009