added generic error handling - for lazy people. :)

This commit is contained in:
mike.morgan%oregonstate.edu 2005-08-09 00:31:56 +00:00
parent 539456bf48
commit 1d40a2f6f1
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
/**
* Basic error functions for triggering fatal runtime errors.
* This class is generally called when a page load should be terminated because of bad inputs.
*
* @package amo
* @subpackage lib
*/
/**
* @param string $error
*/
function triggerError($errorMessage=null,$errorTemplate='error.tpl')
{
$tpl =& new AMO_Smarty();
$tpl->assign(
array(
'error'=>$errorMessage,
'content'=>$errorTemplate,
'backtrace'=>debug_backtrace()
)
);
$tpl->display('inc/wrappers/nonav.tpl');
exit;
}

View File

@ -0,0 +1,18 @@
<h1>Error Found</h1>
<p>The was an error processing your request. Please check your inputs and try again.</p>
<dl>
{if $error}
<dt>Error Message</dt>
<dd>{$error}</dd>
{/if}
<dt>Backtrace</dt>
<dd><pre>
{foreach name=rows item=row from=$backtrace}
{foreach name=row key=key item=item from=$row}
{$key}: {$item}
{/foreach}
{/foreach}
</pre></dd>
</dl>