Default error handler

@param $__exc_errno
@param $__exc_errstr
@param $__exc_errfile
@param $__exc_errline
@param $__exc_errcontext
@return bool
432781
public static function handleError($__exc_errno, $__exc_errstr, $__exc_errfile, $__exc_errline, $__exc_errcontext)
    {
        // If a command is called with "@", then we should return
        if (error_reporting() == 0) {
            return true;
        }

        if (class_exists('\QApplicationBase')) {
            \QApplicationBase::$ErrorFlag = true;
        }

        global $__exc_strType;
        if (isset($__exc_strType)) {
            return true;
        } // Already handled elsewhere, avoi looping

        $__exc_strType = "Error";
        //$__exc_strMessage = $__exc_errstr;

        switch ($__exc_errno) {
            case E_ERROR:
                $__exc_strObjectType = "E_ERROR";
                break;
            case E_WARNING:
                $__exc_strObjectType = "E_WARNING";
                break;
            case E_PARSE:
                $__exc_strObjectType = "E_PARSE";
                break;
            case E_NOTICE:
                $__exc_strObjectType = "E_NOTICE";
                break;
            case E_STRICT:
                $__exc_strObjectType = "E_STRICT";
                break;
            case E_CORE_ERROR:
                $__exc_strObjectType = "E_CORE_ERROR";
                break;
            case E_CORE_WARNING:
                $__exc_strObjectType = "E_CORE_WARNING";
                break;
            case E_COMPILE_ERROR:
                $__exc_strObjectType = "E_COMPILE_ERROR";
                break;
            case E_COMPILE_WARNING:
                $__exc_strObjectType = "E_COMPILE_WARNING";
                break;
            case E_USER_ERROR:
                $__exc_strObjectType = "E_USER_ERROR";
                break;
            case E_USER_WARNING:
                $__exc_strObjectType = "E_USER_WARNING";
                break;
            case E_USER_NOTICE:
                $__exc_strObjectType = "E_USER_NOTICE";
                break;
            case E_DEPRECATED:
                $__exc_strObjectType = 'E_DEPRECATED';
                break;
            case E_USER_DEPRECATED:
                $__exc_strObjectType = 'E_USER_DEPRECATED';
                break;
            case E_RECOVERABLE_ERROR:
                $__exc_strObjectType = 'E_RECOVERABLE_ERROR';
                break;
            default:
                $__exc_strObjectType = "Unknown";
                break;
        }

        $__exc_strFilename = $__exc_errfile;
        $__exc_intLineNumber = $__exc_errline;

        $__exc_strStackTrace = QcubedGetBacktrace();

        if (ob_get_length()) {
            $__exc_strRenderedPage = ob_get_contents();
            ob_clean();
        }

        // Call to display the Error Page (as defined in configuration.inc.php)
        if (defined('QCUBED_ERROR_PAGE_PHP')) {
            require(__DOCROOT__ . QCUBED_ERROR_PAGE_PHP);
        } else {
            // Error in installer or similar - QCUBED_ERROR_PAGE_PHP constant is not defined yet.
            echo "error: errno: " . $__exc_errno . "<br/>" . $__exc_errstr . "<br/>" . $__exc_errfile . ":" . $__exc_errline . "<br/>" . implode(', ',
                    $__exc_errcontext);
        }
        exit();
    }
661968
private function catchWarning($errno, $errstr, $errfile, $errline)
    {
        $this->setError(array(
            'error' => "Connecting to the POP3 server raised a PHP warning: ",
            'errno' => $errno,
            'errstr' => $errstr,
            'errfile' => $errfile,
            'errline' => $errline
        ));
    }
399858
public static function handleError($errno, $errstr, $errfile, $errline, $errcontext, $isException = false)
    {
        $error = array(
            'number' => $errno,
            'desc' => $errstr,
            'file' => $errfile,
            'line' => $errline,
            'context' => $errcontext,
            'isException' => $isException,
        );
        $handled = false;
        if ($isException) {
            $handled = static::call(get_class($errcontext), $handled);
        }
        if (!$handled) {
            static::$errors[] = $error;
        }
    }
268259
public function handler($errno, $errstr, $errfile, $errline)
    {
        throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
    }
979176
private function handleMustacheErrors($errno, $errstr, $errfile, $errline)
    {
        if (!empty($this->lastTemplate)) {
            if (function_exists('newrelic_add_custom_parameter')) {
                call_user_func(
                    'newrelic_add_custom_parameter',
                    'contactclientToken',
                    $this->lastTemplate
                );
            }
        }
        if (!empty($this->context)) {
            if (function_exists('newrelic_add_custom_parameter')) {
                call_user_func(
                    'newrelic_add_custom_parameter',
                    'contactclientContext',
                    json_encode($this->context)
                );
            }
        }
        $this->logger->error(
            'Contact Client '.$this->contactClient->getId().
            ': Warning issued with Template: '.$this->lastTemplate.' Context: '.json_encode($this->context)
        );

        return true;
    }
1226203
public function customErrorHandler($errno, $errstr) {
		if ($this->_isActive('phpException')) {
			$check = 'phpException';
			$level = $this->_config->getTestLevel($check);
			if ($level === null) {
				$level = WARNING;
			}
			$message = $this->_getMessage('PHP_EXPCEPTION', $errstr);

			$this->_writeError($check, $message, $this->lineNumber, $level);
		}

		/* Don't execute PHP internal error handler */
		return false;
	}
207587
public function errorHandler($errno, $errstr, $file, $line)
    {
        switch ($errno) {
            case E_USER_ERROR:
            case E_ERROR:
            case E_RECOVERABLE_ERROR:
                $this->logger->addError($errstr, array($file, $line));
                exit();
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $this->logger->addWarning($errstr, array($file, $line));
                break;
            default:
                $this->logger->addInfo($errstr, array($file, $line));
                break;
        }
    }
45608
static public function handleSilentWriteClose($errno, $errstr, $errfile, $errline, $errcontext)
    {
        self::$sessionStartError .= PHP_EOL . $errfile . '(Line:' . $errline . '): Error #' . $errno . ' ' . $errstr;
    }
55588
public function handleError($errNo, $errStr, $errFile, $errLine, $errContext = array(), Metadata $metadata = null)
	{
		if (0 === error_reporting())
		{
			return $this;
		}

		$error    = new ErrorException($errStr, $errNo, $errFile, $errLine, $errContext);
		$metadata = $this->getMetadata($metadata, $error);

		if (false === $this->shouldHandle($metadata))
		{
			return $this;
		}

		$categories = $metadata->getCategories();

		foreach ($this->handlerManager->all($categories) as $handler)
		{
			$handler->handleError($error, $metadata);
		}

		$this->stats->addError();

		return $this;
	}
497981
public static function handlerError($errno, $errstr, $errfile, $errline)
    {
        $bad = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR);

        // set log file name
        switch ($errno) {
            case E_ERROR:             $fn = "error";                 break;
            case E_WARNING:           $fn = "warning";               break;
            case E_PARSE:             $fn = "parse";                 break;
            case E_NOTICE:            $fn = "notice";                break;
            case E_CORE_ERROR:        $fn = "core_error";            break;
            case E_CORE_WARNING:      $fn = "core_warning";          break;
            case E_COMPILE_ERROR:     $fn = "compile_error";         break;
            case E_COMPILE_WARNING:   $fn = "compile_warning";       break;
            case E_USER_ERROR:        $fn = "user_error";            break;
            case E_USER_WARNING:      $fn = "user_warning";          break;
            case E_USER_NOTICE:       $fn = "user_notice";           break;
            case E_STRICT:            $fn = "strict";                break;
            case E_RECOVERABLE_ERROR: $fn = "recoverable_error";     break;
            case E_DEPRECATED:        $fn = "deprecated";            break;
            case E_USER_DEPRECATED:   $fn = "user_deprecated";       break;
            case E_ALL:               $fn = "all";                   break;
            default:                  $fn = "__{$errno}__undefined"; break;
        }

        if(defined('PATH_ROOT')) {
            $errfile = str_replace(realpath(PATH_ROOT), '', $errfile);
        }

        $err_msg = strtoupper($fn) . ": {$errstr}\nLINE: {$errline}\nFILE: {$errfile}";

        // With this setup errors are displayed according to the error_reporting() setting
        // but all errors are logged to file, regardles of
        if(defined('DEBUG') && DEBUG && error_reporting() & $errno) {
            echo self::_skipFormating()
                ? $err_msg . PHP_EOL
                : sprintf("<pre>\n<p style='%s'>\n%s\n</p>\n</pre>\n\n", self::getFormattedCss(), $err_msg);
        }

        // all errors are logged
        if(!empty($fn)) {
            self::_writeLog($fn . self::$_extenstion, $err_msg);
            self::_writeLogJson($fn, $errstr, $errno, $errline, $errfile, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
        }

        // On production setup, if bad errors occurs, send mail with parsed exception and terminate the script
        // DISABLED FOR NOW SINCE IT'S KILLING US AT THE MOMENT!!!!!
        // SWITCH TO EVENTS!!!!!
//         if(in_array($errno, $bad)) {
//             if(defined('DEBUG') && !DEBUG) {
//                 try {
//                     throw new \Exception($errstr);
//                 } catch (\Exception $e) {
//                     $msg = self::_parseException($e);
//                 }

//                 defined('EMAIL_DEBUG')
//                 && defined('EMAIL_DEBUG_FROM')
//                 && @mail (EMAIL_DEBUG, "PHP ERROR: {$errstr}", $msg, 'From: ' . EMAIL_DEBUG_FROM);
//             }
//             exit(1);
//         }
    }
29819
protected function output($errno, $errstr, $errfile, $errline, $errcontext)
    {
        $reporter = Debug::create_debug_view();

        // Coupling alert: This relies on knowledge of how the director gets its URL, it could be improved.
        $httpRequest = null;
        if (isset($_SERVER['REQUEST_URI'])) {
            $httpRequest = $_SERVER['REQUEST_URI'];
        }

        if (isset($_SERVER['REQUEST_METHOD'])) {
            $httpRequest = $_SERVER['REQUEST_METHOD'] . ' ' . $httpRequest;
        }

        $output = $reporter->renderHeader();
        $output .= $reporter->renderError($httpRequest, $errno, $errstr, $errfile, $errline);

        if (file_exists($errfile)) {
            $lines = file($errfile);

            // Make the array 1-based
            array_unshift($lines, "");
            unset($lines[0]);

            $offset = $errline-10;
            $lines = array_slice($lines, $offset, 16, true);
            $output .= $reporter->renderSourceFragment($lines, $errline);
        }
        $output .= $reporter->renderTrace($errcontext);
        $output .= $reporter->renderFooter();

        return $output;
    }
341788
public function error_function($errno, $errstr, $errfile, $errline, $errcontext){
    	$this->provider('log')->exception('error_function',
    		array('errno' => $errno,'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline, 'errcontext' => $errcontext));
        require $this->plume('plume.root.path').$this->plume('plume.templates.500');
        die();
        // return false;//如果函数返回 FALSE，标准错误处理处理程序将会继续调用。
    }
1130080
protected function cleanup_error_handler()
    {
        restore_error_handler();

        if ($this->last_error !== null) {
            throw new \ErrorException(
                $this->last_error['errstr'],
                0,
                $this->last_error['errno'],
                $this->last_error['errfile'],
                $this->last_error['errline']
            );
        }
    }
1220949
function onErrorHandle($errno, $errstr, $errfile, $errline)
    {
        $error = array(
            'message' => $errstr,
            'file' => $errfile,
            'line' => $errline,
        );
        $this->errorResponse($error);
    }
1044099
public function triggerError($iErrorNumber = 0, $sErrorString = '', $sErrorFile = '', $iErrorLine = 0)
    {
        //  PHP5.6 doesn't like $this->sDriverClass::error()
        $sDriverClass = static::$sDriverClass;
        $sDriverClass::error($iErrorNumber, $sErrorString, $sErrorFile, $iErrorLine);
    }
31358
public static function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
    {
        Daemon::$noError = false;
        $l = error_reporting();
        if ($l === 0) {
            if (!Daemon::$restrictErrorControl) {
                return;
            }
        } elseif (!($l & $errno)) {
            return;
        }

        static $errtypes = [
            E_ERROR => 'Fatal error',
            E_WARNING => 'Warning',
            E_PARSE => 'Parse error',
            E_NOTICE => 'Notice',
            E_PARSE => 'Parse error',
            E_USER_ERROR => 'Fatal error (userland)',
            E_USER_WARNING => 'Warning (userland)',
            E_USER_NOTICE => 'Notice (userland)',
            E_STRICT => 'Notice (userland)',
            E_RECOVERABLE_ERROR => 'Fatal error (recoverable)',
            E_DEPRECATED => 'Deprecated',
            E_USER_DEPRECATED => 'Deprecated (userland)',
        ];
        $errtype = $errtypes[$errno];
        Daemon::log($errtype . ': ' . $errstr . ' in ' . $errfile . ':' . $errline . "\n" . Debug::backtrace());
        if (Daemon::$context instanceof \PHPDaemon\Request\Generic) {
            Daemon::$context->out('<strong>' . $errtype . '</strong>: ' . $errstr . ' in ' . basename($errfile) . ':' . $errline . '<br />');
        }
    }
492122
public function errorHandler($errno, $errstr, $errfile, $errline)
    {
        preg_match('/(ORA-)(\d+)/', $errstr, $ora_error);
        if ($ora_error) {
            $this->_last_error = intval($ora_error[2]);
        } else {
            $this->setError($this->_con);
        }
    }