Code: Select all
<?php
echo "There was an error!";
?>So.. I've started designing a class for my error handling. Or should I say, error-message-server. The logging and so forth is fine, but when it comes to showing the user the error message, it sucks.
Why does it suck?
Well, for some errors my View hasn't been instantiated until after, such as authentication error(s) thus there isn't always a View to call/pass.
So..
My error class currently looks like:
Code: Select all
class Error
{
private static $config;
public static function setConfig ($config)
{
self::$config = $config;
}
public static function setException ($e)
{
self::display($e->getMessage());
}
public static function setError ($e)
{
self::display($e);
}
private static function display ($msg)
{
$view = new jmt_View(new Smarty);
$view->assignVariable('message', $msg);
$view->assignVariable('stylesheet', self::$config['STYLESHEET']);
$view->setTemplate('message.tpl');
$view->displayPage();
die;
}
}I'm a bit brainfried atm and so I ask for ideas/suggestions from the kind fellows of PHPDN, how would I achieve the same functionality, but in a much lesser maintenance heavy fashion? (e.g. if I change out Smarty for something else I'll need to change not only my View class (which is a wrapper for Smarty) but my Error class as well..)
Much obliged.