Zend + Smarty で Struts 調の例外ページ
Zendのエラー画面にこんなテーブルを表示させたい。
class | Zend_Controller_Dispatcher_Exception |
code | 0 |
message | Invalid controller specified (hoge) |
file | C:\Program Files\PHP\lib\Zend\library\Zend\Controller\Dispatcher\Standard.php(241) | trace | C:\Program Files\PHP\lib\Zend\library\Zend\Controller\Front.php(934) Zend_Controller_Dispatcher_Standard->dispatch |
error/error.tpl
<table border="1">
<tr>
<td>class</td>
<td>{$exception|get_class}</td>
</tr>
<tr>
<td>code</td>
<td>{$exception->getCode()}</td>
</tr>
<tr>
<td>message</td>
<td>{$exception->getMessage()}</td>
</tr>
<tr>
<td>file</td>
<td>{$exception->getFile()}({$exception->getLine()})</td>
</tr>
</tr>
<td>trace</td>
<td>
{foreach from=$exception->getTrace() item='trace' name="loop1"}
{" "|str_repeat:$smarty.foreach.loop1.index*2}
{$trace.file}({$trace.line})<br />
{" "|str_repeat:$smarty.foreach.loop1.index*2}
{$trace.class}{$trace.type|smarty:nodefaults}{$trace.function}
({foreach from=$trace.args item='arg'}
{$arg|gettype}
{if $arg|is_object}
{$arg|get_class},
{else}
{if $arg|is_array}
{$arg|var_export},
{else}
{$arg},
{/if}
{/if}
{/foreach})<br /><br />
{/foreach}
</td>
</tr>
</table>
ErrorController::errorAction()の中に
<?php $errors = $this->_getParam('error_handler'); $this->view->assign('exception',$errors->offsetGet('exception'));