If we are in this class, we must assume that the application is in an unstable state. Thus, we cannot depend on any other qcodo or application-based classes or objects to help with the error processing. Therefore, all classes and functionality for error handling must be defined in this class in order to minimize any dependency on the rest of the framework.
Example #1
0
 public static function HandleError($intErrorNumber, $strErrorString, $strErrorFile, $intErrorLine)
 {
     // If a command is called with "@", then we should return
     if (error_reporting() == 0) {
         return;
     }
     // If we still have access to QApplicationBase, set the error flag on the Application
     if (class_exists('QApplicationBase')) {
         QApplicationBase::$ErrorFlag = true;
     }
     // If we are currently dealing with reporting an error, don't go on
     if (QErrorHandler::$Type) {
         return;
     }
     // Setup the QErrorHandler Object
     QErrorHandler::$Type = 'Exception';
     QErrorHandler::$Message = $strErrorString;
     QErrorHandler::$Filename = $strErrorFile;
     QErrorHandler::$LineNumber = $intErrorLine;
     switch ($intErrorNumber) {
         case E_ERROR:
             QErrorHandler::$ObjectType = 'E_ERROR';
             break;
         case E_WARNING:
             QErrorHandler::$ObjectType = 'E_WARNING';
             break;
         case E_PARSE:
             QErrorHandler::$ObjectType = 'E_PARSE';
             break;
         case E_NOTICE:
             QErrorHandler::$ObjectType = 'E_NOTICE';
             break;
         case E_STRICT:
             QErrorHandler::$ObjectType = 'E_STRICT';
             break;
         case E_CORE_ERROR:
             QErrorHandler::$ObjectType = 'E_CORE_ERROR';
             break;
         case E_CORE_WARNING:
             QErrorHandler::$ObjectType = 'E_CORE_WARNING';
             break;
         case E_COMPILE_ERROR:
             QErrorHandler::$ObjectType = 'E_COMPILE_ERROR';
             break;
         case E_COMPILE_WARNING:
             QErrorHandler::$ObjectType = 'E_COMPILE_WARNING';
             break;
         case E_USER_ERROR:
             QErrorHandler::$ObjectType = 'E_USER_ERROR';
             break;
         case E_USER_WARNING:
             QErrorHandler::$ObjectType = 'E_USER_WARNING';
             break;
         case E_USER_NOTICE:
             QErrorHandler::$ObjectType = 'E_USER_NOTICE';
             break;
         default:
             QErrorHandler::$ObjectType = 'Unknown';
             break;
     }
     // Setup the Stack Trace
     QErrorHandler::$StackTrace = "";
     $objBackTrace = debug_backtrace();
     for ($intIndex = 0; $intIndex < count($objBackTrace); $intIndex++) {
         $objItem = $objBackTrace[$intIndex];
         $strKeyFile = array_key_exists('file', $objItem) ? $objItem['file'] : '';
         $strKeyLine = array_key_exists('line', $objItem) ? $objItem['line'] : '';
         $strKeyClass = array_key_exists('class', $objItem) ? $objItem['class'] : '';
         $strKeyType = array_key_exists('type', $objItem) ? $objItem['type'] : '';
         $strKeyFunction = array_key_exists('function', $objItem) ? $objItem['function'] : '';
         QErrorHandler::$StackTrace .= sprintf("#%s %s(%s): %s%s%s()\n", $intIndex, $strKeyFile, $strKeyLine, $strKeyClass, $strKeyType, $strKeyFunction);
     }
     QErrorHandler::Run();
 }
Example #2
0
 protected function ParseColumnText($objColumn, $objObject)
 {
     $_ITEM = $objObject;
     $_FORM = $this->objForm;
     $_CONTROL = $this;
     $_COLUMN = $objColumn;
     $strHtml = $objColumn->Html;
     $intPosition = 0;
     while (($intStartPosition = strpos($strHtml, '<?=', $intPosition)) !== false) {
         $intEndPosition = strpos($strHtml, '?>', $intStartPosition);
         if ($intEndPosition === false) {
             return $strHtml;
         }
         $strToken = substr($strHtml, $intStartPosition + 3, $intEndPosition - $intStartPosition - 3);
         $strToken = trim($strToken);
         if ($strToken && !strpos($strToken, 'ToStringHoverTips($_CONTROL)') > 0) {
             // Because Eval doesn't utilize exception management, we need to provide the QErrorHandler with additional
             // information in case soething goes wrong
             QErrorHandler::$AdditionalMessage = sprintf("Incorrectly formatted DataGridColumn HTML in %s '%s': %s", get_class($this), $this->strControlId, $strHtml);
             try {
                 $strEvaledToken = eval(sprintf('return %s;', $strToken));
             } catch (QCallerException $objExc) {
                 $objExc->DecrementOffset();
                 throw $objExc;
             }
             // Clear additional information from error handler
             QErrorHandler::$AdditionalMessage = null;
         } else {
             $strEvaledToken = '';
         }
         $strHtml = sprintf("%s%s%s", substr($strHtml, 0, $intStartPosition), $strEvaledToken, substr($strHtml, $intEndPosition + 2));
         $intPosition = $intStartPosition + strlen($strEvaledToken);
     }
     return $strHtml;
 }
Example #3
0
function __qcodo_handle_error($intErrorNumber, $strErrorString, $strErrorFile, $intErrorLine)
{
    return QErrorHandler::HandleError($intErrorNumber, $strErrorString, $strErrorFile, $intErrorLine);
}
Example #4
0
 /**
  * Error handler for triggered errors.
  *
  * @param int    $errno    Error number. E_%
  * @param string $errstr   Error message
  * @param string $errfile  File where error occured
  * @param int    $errline  Line where error occured
  */
 protected function onError($errno, $errstr, $errfile, $errline)
 {
     self::$lastError = array('type' => $errno, 'message' => $errstr, 'file' => $errfile, 'line' => $errline);
     if (!(error_reporting() & $errno)) {
         return;
     }
     if (count($this->currentErrors) > 100 || array_search("{$errfile}#{$errline}/{$errno}:{$errstr}", $this->currentErrors) !== false) {
         // There is an error in error handling or recurring errors should be ignored. The error already logged once, so just ignore.
         return;
     }
     $this->currentErrors[] = "{$errfile}#{$errline}/{$errno}:{$errstr}";
     $this->log($errno, array('error' => self::errorDescription($errno), 'message' => $errstr, 'file' => $errfile, 'line' => $errline, 'trace' => debug_backtrace()));
     if ($errno & E_FATAL) {
         $this->exitOnError();
     }
     if (!$this->ignoreRepeatedErrors) {
         array_pop($this->currentErrors);
     }
 }
Example #5
0
foreach ($__exc_ObjVariableArrayKeys as $__exc_Key) {
    if (strpos($__exc_Key, "__exc_") === false && strpos($__exc_Key, "_DATE_") === false && $__exc_Key != "GLOBALS") {
        try {
            if ($__exc_Key == 'HTTP_SESSION_VARS' || $__exc_Key == '_SESSION') {
                $__exc_ObjSessionVarArray = array();
                foreach (${$__exc_Key} as $__exc_StrSessionKey => $__exc_StrSessionValue) {
                    if (strpos($__exc_StrSessionKey, 'qform') !== 0) {
                        $__exc_ObjSessionVarArray[$__exc_StrSessionKey] = $__exc_StrSessionValue;
                    }
                }
                $__exc_StrVarExport = htmlentities(var_export($__exc_ObjSessionVarArray, true));
            } else {
                $__exc_StrVarExport = QErrorHandler::VarExport($__exc_ObjVariableArray[$__exc_Key]);
            }
            $__exc_StrToDisplay .= sprintf("  <a href=\"javascript:RenderPage(%s)\" title=\"%s\">%s</a>\n", $__exc_Key, $__exc_StrVarExport, $__exc_Key);
            $__exc_StrToScript .= sprintf("  %s = \"<pre>%s</pre>\";\n", $__exc_Key, QErrorHandler::PrepDataForScript($__exc_StrVarExport));
        } catch (Exception $__exc_objExcOnVarDump) {
            $__exc_StrToDisplay .= sprintf("  Fatal error:  Nesting level too deep - recursive dependency?\n", $__exc_objExcOnVarDump->Message);
        }
    }
}
_p($__exc_StrToDisplay . '</pre>', false);
printf('<script type="text/javascript">%s</script>', $__exc_StrToScript);
?>
			</div><br />
			<hr width="100%" size="1" color="#dddddd" />
			<center><em>
				<?php 
_p(QErrorHandler::$Type);
?>
 Report Generated:&nbsp;&nbsp;<?php 
 /**
  * Called by QApplication::Initialize() to setup error and exception handling
  * to use the Qcodo Error/Exception handler.
  * @return void
  */
 protected static function InitializeErrorHandling()
 {
     QErrorHandler::$CliMode = QApplication::$CliMode;
     set_error_handler('__qcodo_handle_error', error_reporting());
     set_exception_handler('__qcodo_handle_exception');
 }
 /**
  * Called by QApplication::Initialize() to setup error and exception handling
  * to use the Qcodo Error/Exception handler.
  * @return void
  */
 protected static function InitializeErrorHandling()
 {
     QErrorHandler::$CliMode = QApplication::$CliMode;
     set_error_handler(array('QErrorHandler', 'HandleError'), error_reporting());
     set_exception_handler(array('QErrorHandler', 'HandleException'));
 }