Catches all the PHP errors and convert them into a PHP exception

@param int $error_number
@param string $error
@param string $error_file
@param int $error_line

@throws PHPException
435651
public function handlePHPError($error_number, $error, $error_file, $error_line)
	{
		// respect the current error_reporting setting
		if((error_reporting() & $error_number) === 0)
			return;
		
		throw new PHPException($error_number, $error, $error_file, $error_line);
	}
1082792
public function errorHandler($code, $message, $file, $line)
    {
        switch ($code) {
            case E_NOTICE:
            case E_USER_NOTICE:
                $exception = new Errors\Notice($message, $code, 1, $file, $line);
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $exception = new Errors\Warning($message, $code, 1, $file, $line);
                break;
            case E_ERROR:
            case E_CORE_ERROR:
            case E_RECOVERABLE_ERROR:
            case E_USER_ERROR:
                $exception = new Errors\Fatal($message, $code, 1, $file, $line);
                break;
            default:
                $exception = new Errors\Error($message, $code, 1, $file, $line);
                break;
        }

        $this->exceptionHandler($exception);

        if ($this->oldErrorHandler) {
            return call_user_func(
                $this->oldErrorHandler,
                $code,
                $message,
                $file,
                $line
            );
        }

        return false;
    }
942642
public function handleErrors($code, $message, $file, $line)
    {
        throw new ErrorException($message, 0, $code, $file, $line);
    }
526190
static public function errorHandler($errorNumber, $errorString, $errorFile, $errorLine)
    {

        /*
         * Is line has been suppressed with an @, do not throw an exception
         */
        if (error_reporting() == 0) {
            return;
        }

        $errorFullText = self::formatErrorText($errorNumber, $errorString, $errorFile, $errorLine);

        /*
     * Hold execution
     */
        if (self::$errorHoldsExecution) {
            throw new DebugException ($errorFullText, $errorNumber);
        } else {
            /*
     * display error
     */
            if (self::$displayErrors) {
                echo self::displayBox();
            }
            /*
       * Message error
       */
            if (self::$displayTrace) {
                echo self::formatError($errorFullText);
            }

            /*
     * Send message do psHelpdesk
     */
            if (self::$sendTrace) {
                self::send($errorFullText);
            }
        }

    }
268259
public function handler($errno, $errstr, $errfile, $errline)
    {
        throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
    }
180100
public static function throwErrorException($errno, $errstr, $errfile, $errline)
    {
        if (error_reporting() & $errno) { //check if error level is set
            throw new \ErrorException(
                sprintf('%s: %s', self::getErrorTypeString($errno), $errstr),
                0,
                $errno,
                $errfile,
                $errline
            );
        }
    }
1301552
private function _log_to_file($error_text)
    {
        try {
            $dir_name = 'logs';
            if (!is_dir($dir_name)) {
                mkdir($dir_name);
            }
            $fileName = $dir_name.'/'.__CLASS__.'-'.date('Y-m-d').'.txt';
            $myFile = fopen($fileName, 'a+');
            $date = '============[Date]============';
            $date .= "\n";
            $date .= '[ '.date('Y-m-d H:i:s  e').' ] ';
            fwrite($myFile, $date.$error_text."\n\n");
            fclose($myFile);
        } catch (\Exception $e) {
            echo $e->getMessage();
        }
    }
362574
function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
	$file = null, $line = null, $error_type = E_USER_ERROR)
	{
		if(isset($file) && isset($line)) {
			$info = ' ('.basename($file).", line $line)";
		} else {
			$info = '';
		}
		if (isset($tpl_line) && isset($tpl_file)) {
			$this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
		} else {
			$this->trigger_error($error_msg . $info, $error_type);
		}
	}
413943
protected function _errorhandler_output($errstr, $backtrace, $errortype) {
		// output error
		$error = '<div class="dp_container">';
		$error .= '<div class="skyline">'.$errortype.'</div>';
		$error .= '<h1 class="exception">'.htmlspecialchars($errstr, ENT_QUOTES, 'UTF-8').'</h1>';

		$count = 0;
		foreach ($backtrace as $key => $value) {
			// only if file is available
			if (!empty($value['file']) && is_file($value['file'])) {
				$id_file = '_errorhandler_file_'.$this->errorcounter.'_'.$count;
				$id_args = 'errorhandler_args_'.$this->errorcounter.'_'.$count;
				$show = ($count === 0) ? 'style="display: block;"' : '';

				if ($count>0) {
					$call = $value['class'].$value['type'].$value['function'].'()';
					$error .= '<h2>'.$call.'</h2>';
				}

				// highlight the file name
				$file = preg_replace('=[^/]+$=', '<strong>$0</strong>', $value['file']);
				
				$error .= '<h3>'.$file.' (Line '.$value['line'].')</h3>';
				$error .= '<div class="file" id="'.$id_file.'" '.$show.'>'.$this->_getContent($value['file'], $value['line']).'<div style="clear: both;"></div></div>';

				if (count($value['args'])>0 and $count > 0) {
					$dump = htmlspecialchars(print_r($value['args'], true));
					$error .= '<h3>Arguments ('.count($value['args']).')</h3>';
					$error .= '<div class="args" id="'.$id_args.'">'.$dump.'</div>';
				}

				$count++;
			}
		}

		$error .= '</div>';

		// output css and js only at first call
		if ($this->errorcounter === 1) $error .= $this->_debug_styles();

		return $error;
	}
675688
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = null)
    {
        // throwing an exception in an error handler will halt execution
        //   set the last error and continue
        $this->last_error = compact('errno', 'errstr', 'errfile', 'errline', 'errcontext');
    }
456350
public function appendError($error_key, $error_string)
	{
		if($this->getErrors())
		{
			// append
			$this->errors->add( $error_key, $error_string );
		}
		else
		{
			// new MessageBag
			$this->errors = new MessageBag( array($error_key => $error_string) );
		}
	}
1272711
public static function errorHandler($code, $message, $file, $line)
    {

        if (error_reporting() === 0) {
            // This error code is not included in error_reporting
            return false;
        }
        throw new \sb\Exception($code, $message, $file, $line);
    }
926084
static function ErrorHandler($errno, $errstr, $errfile, $errline)
    {
        switch ($errno) {
            case E_ERROR:
                $errtype = ReporticoLang::translate("Error");
                break;
            case E_NOTICE:
                $errtype = ReporticoLang::translate("Notice");
                break;
            case E_USER_ERROR:
                $errtype = ReporticoLang::translate("Error");
                break;
            case E_USER_WARNING:
                $errtype = ReporticoLang::translate("");
                break;
            case E_USER_NOTICE:
                $errtype = ReporticoLang::translate("");
                break;
            case E_WARNING:
                $errtype = ReporticoLang::translate("");
                break;

            default:
                $errtype = ReporticoLang::translate("Fatal Error");

        }
        
        
        // If request parameter errorsInModal is set then popup first user error
        // back to client and exit. This is to popup errors when probles in saving reports
        if ( ReporticoUtility::getRequestItem("errorsInModal") && $errno == E_USER_ERROR ) {


            header("HTTP/1.0 404 Not Found", true);
            echo $errstr;
            die;


        }
        // Avoid adding duplicate errors
        $errors = &self::getSystemErrors();
        $ct = 0;
        foreach ( self::getSystemErrors() as $k => $val) {
            if ($val["errstr"] == $errstr) {
                $errors[$k]["errct"] = $ct+1;
                return;
            }
        }

        $errors[] =
                array(
                "errno" => $errno,
                "errstr" => $errstr,
                "errfile" => $errfile,
                "errline" => $errline,
                "errtype" => $errtype,
                "errarea" => self::get("code_area"),
                "errsource" => self::get("code_source"),
                "errct" => 1,
                );
        //echo "<PRE>";
        //var_dump($errors);
        //echo "</PRE>";

        self::set("error_status", 1);

    }
1197595
public function getFriendlyUploadError($error_code = '') {
		switch ($error_code) {
			case UPLOAD_ERR_OK:
				return '';

			case UPLOAD_ERR_INI_SIZE:
				$key = 'ini_size';
				break;

			case UPLOAD_ERR_FORM_SIZE:
				$key = 'form_size';
				break;

			case UPLOAD_ERR_PARTIAL:
				$key = 'partial';
				break;

			case UPLOAD_ERR_NO_FILE:
				$key = 'no_file';
				break;

			case UPLOAD_ERR_NO_TMP_DIR:
				$key = 'no_tmp_dir';
				break;

			case UPLOAD_ERR_CANT_WRITE:
				$key = 'cant_write';
				break;

			case UPLOAD_ERR_EXTENSION:
				$key = 'extension';
				break;

			default:
				$key = 'unknown';
				break;
		}

		return elgg_echo("upload:error:$key");
	}
472108
public function triggerError($error_message = null, $error_type = null) {

        if ($error_message !== null && $error_type !== null) {
            trigger_error($error_message, $error_type);
        }
    }
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;
        }
    }
314050
public function error($errno, $error, $file, $line) {
        try {
            throw new MyException($error, $errno, $file, $line);
        } catch (MyException $e) {
            ERRORCODE($e);
        }
    }