Exemplo n.º 1
0
 /**
  * creates a new patError object given the specified information.
  *
  * @access	public
  * @param	int		$level	The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.
  * @param	string	$code	The application-internal error code for this error
  * @param	string	$msg	The error message, which may also be shown the user if need be.
  * @param	mixed	$info	Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).
  * @return	mixed	$error	The configured patError object or false if this error should be ignored
  * @see		patError
  * @todo		implement 'simple' mode that returns just false (BC for patConfiguration)
  * @todo		either remove HTML tags and entities from output or test for enviroment!!! <b></b> in shell is ugly!
  */
 function &raise($level, $code, $msg, $info = null)
 {
     // ignore this error?
     if (in_array($code, $GLOBALS['_pat_errorIgnores'])) {
         return false;
     }
     // this error was expected
     if (!empty($GLOBALS['_pat_errorExpects'])) {
         $expected = array_pop($GLOBALS['_pat_errorExpects']);
         if (in_array($code, $expected)) {
             return false;
         }
     }
     // need patError
     $class = $GLOBALS['_pat_errorClass'];
     if (!class_exists($class)) {
         include_once dirname(__FILE__) . '/' . $class . '.php';
     }
     // build error object
     $error = new $class($level, $code, $msg, $info);
     // see what to do with this kind of error
     $handling = patErrorManager::getErrorHandling($level);
     $function = 'handleError' . ucfirst($handling['mode']);
     if (is_callable(array('patErrorManager', $function))) {
         return patErrorManager::$function($error, $handling);
     } else {
         // This is required to prevent a very unhelpful white-screen-of-death
         jexit('JError::raise -> Static method JError::' . $function . ' does not exist.' . ' Contact a developer to debug' . '<br /><strong>Error was</strong> ' . '<br />' . $error->getMessage());
     }
 }
Exemplo n.º 2
0
 /**
  * creates a new patError object given the specified information.
  *
  * @access	public
  * @param	int		$level	The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.
  * @param	string	$code	The application-internal error code for this error
  * @param	string	$msg	The error message, which may also be shown the user if need be.
  * @param	mixed	$info	Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).
  * @return	mixed	$error	The configured patError object or false if this error should be ignored
  * @see		patError
  * @todo		implement 'simple' mode that returns just false (BC for patConfiguration)
  * @todo		either remove HTML tags and entities from output or test for enviroment!!! <b></b> in shell is ugly!
  */
 function &raise($level, $code, $msg, $info = null)
 {
     // ignore this error?
     if (in_array($code, $GLOBALS['_pat_errorIgnores'])) {
         return false;
     }
     // this error was expected
     if (!empty($GLOBALS['_pat_errorExpects'])) {
         $expected = array_pop($GLOBALS['_pat_errorExpects']);
         if (in_array($code, $expected)) {
             return false;
         }
     }
     // need patError
     $class = $GLOBALS['_pat_errorClass'];
     if (!class_exists($class)) {
         include_once dirname(__FILE__) . '/' . $class . '.php';
     }
     // build error object
     $error = new $class($level, $code, $msg, $info);
     // see what to do with this kind of error
     $handling = patErrorManager::getErrorHandling($level);
     $function = 'handleError' . ucfirst($handling['mode']);
     return patErrorManager::$function($error, $handling);
 }