<?php
/**
* Part of Showkase web site management package
*
* @package Showkase
* @author Jack Hardie {@link http://www.jhardie.com}
* @copyright Copyright (c) 2012, SimpleViewer Inc.
*/
defined('SK_ACCESS')||die('<h1>403: Forbidden</h1>');
/**
* Error handler class
* E_USER_NOTICE should rarely if ever be used. It's simpler and clearer to pass a message to the site singleton.
* E_USER_WARNING is useful for errors where there is no need to stop execution at the point of error
* E_USER_ERROR is not used. Exceptions are used instead
*
* @package Showkase
*/
Class ErrorHandler
{
/**
* Constructs ErrorHandler
*
* @param object
* @param string error handler
*/
function __construct()
{
set_error_handler(array($this, 'handleError'));
}
/**
* Custom error handler
*
* Errors suppressed with @ are not dealt with (error level 0)
* Errors in auth.php are dealt with even if the error level is 0
* @return boolean true will suppress normal error messages
* @param int error level
* @param string error message
* @param string php script where error occurred
* @param int line number in php script
* @param array global variables
*/
function handleError($errLevel, $errorMessage, $errFile, $errLine, $errContext)
{
$debugInfo = DEBUG ? ' ('.basename($errFile).', line '.$errLine.')' : '';
switch ($errLevel) {
case E_USER_NOTICE :
Board::addMessage('Notice: '.$errorMessage, 'notice');
break;
case E_NOTICE :
// avoid double error reporting if php errors are suppressed
if (error_reporting() == 0) break;
Board::addMessage('Notice: '.$errorMessage.$debugInfo, 'notice');
break;
case E_USER_WARNING :
Board::addMessage('Warning: '.$errorMessage.$debugInfo, 'warning');
break;
case E_WARNING :
// avoid double error reporting if php errors are suppressed
if (error_reporting() == 0) break;
Board::addMessage('Warning: '.$errorMessage.$debugInfo, 'warning');
break;
default :
// E_ERROR
return false;
}
return true;
}
}