Handles PHP errors that may occur.

@param int    $errno   the error no
@param string $message error message
@param string $file    the file name
@param string $line    the line number
@param array  $context the error context

@return bool TRUE
765022
public function handleError( $errno, $message = '', $file = '', $line = '', $context = [ ] )
    {
        // restore previous error handler
        restore_error_handler();

        if ( $errno === NULL )
        {
            $error = error_get_last();

            $error = [
                'file'    => $error[ 'file' ],
                'line'    => $error[ 'line' ],
                'message' => $error[ 'message' ],
                'trace'   => $this->getBacktrace( debug_backtrace() ),
            ];
        }
        else
        {
            $error = [
                'message' => $message,
                'file'    => $file,
                'line'    => $line,
                'context' => $context,
            ];
        }

        if ( NULL !== $this->errorCallback )
        {
            call_user_func_array( $this->errorCallback, $error );
        }

        return TRUE;
    }
626181
public function error($errorNumber, $message, $file, $line, $context) {
        $errorReporting = error_reporting();
        $errorEnabled = (bool)($errorReporting & $errorNumber);

        // Ignore errors that are below the current error reporting level.
        if (!$errorEnabled) {
            return false;
        }

        $backtrace = debug_backtrace();
        throw new ErrorException($message, $errorNumber, $file, $line, $context, $backtrace);
    }
36546
public static function err($message, $addEol = true)
    {
        if ($addEol) {
            $message .= PHP_EOL;
        }

        if (\defined('STDERR')) {
            fwrite(STDERR, $message);
        } else {
            echo $message;
        }
    }
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);
//         }
    }
791490
public static function error( $num, $message, $file, $line ) 
	{	
		$exception = new CCException( static::$error_types[$num]." - ".$message, 0, $num, $file, $line );
		
		if ( static::is_fatal_level( $num ) ) 
		{
			if ( static::$in_shutdown_process ) 
			{
				static::exception( $exception );
			} else 
			{
				throw $exception;
			}
		} else 
		{
			static::$non_fatals[] = $exception; 
		}
	}
1069976
public function PHPErrorHandler($error_level, $error_message, $error_file, $error_line, $error_context)
    {
        $message = $error_message . ' | File: {file} | Ln: {line}';
        $context = array(
            'file' => $error_file,
            'line' => $error_line
        );

        switch ($error_level) {
            case E_USER_ERROR:
                // no break
            case E_RECOVERABLE_ERROR:
                $this->logger->error($message, $context);
                break;
            case E_WARNING:
                // no break
            case E_USER_WARNING:
                $this->logger->warning($message, $context);
                break;
            case E_NOTICE:
                // no break
            case E_USER_NOTICE:
                $this->logger->notice($message, $context);
                break;
            case E_STRICT:
                $this->logger->debug($message, $context);
                break;
            default:
                $this->logger->warning($message, $context);
        }
        return;
    }
276454
static public function errorHandler($errno, $errstr, $errfile='', $errline=0, $errcontext=array())
    {
        if (!isset(self::$ignore[basename($errfile) . '-' . $errline . '-' . $errno])) {
            $msg = $errstr . ' Line '
                    . $errline
                    . ', '
                    . $errfile;
            self::$logger->debug($msg);
        }

        return true;
    }
186409
protected function handleError($type, $message, $file, $line)
    {
        throw new ResourceException(sprintf(
            '%s: "%s" in %s on line %d',
            $type,
            $message,
            $file,
            $line
        ));
    }
766318
public static function error_log($errn,$errstr,$file,$line,$context){
		LogMaster::log($errstr." at ".$file." line ".$line);
	}
414461
public function errorHandler($errno, $errstr = '', $errfile = '', $errline = '')
    {
        if (!($errno & error_reporting())) {
            return;
        }
        $this->log->error("Code:{code}\tMsg:{msg}\tFile:{file}\tLine:{line}",
            ['code' => $errno, 'msg' => $errstr, 'file' => $errfile, 'line' => $errline]);
    }
1373902
public static function addErrorMessage($message, $num = E_USER_ERROR, $file = '', $line = 0, $context = array())
	{
		if (is_array($message)) {
			$message = implode(' ', $message);
		}
		$exception = new \ErrorException($message, 0, $num, $file, $line);
		$exception->context = $context;

		return self::addError($exception, true);
	}
677235
public static function error_handler($number, $message, $file, $line)
    {
        $msg = "$message in $file on line $line";
        if (($number !== E_NOTICE) && ($number < 2048)) {
            self::errorMessage($msg, true);
            self::customErrorMsg();
        }
        return 0;
    }
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);
        }
    }
709668
public function errorToException($level = 0, $message = '', $file = null, $line = 0, $context = array())
    {
        $deprecated = false;
        switch ($level) {
            case E_DEPRECATED:
            case E_USER_DEPRECATED:
                $deprecated = true;
                $errors = "Deprecated";
                break;
            case E_NOTICE:
            case E_USER_NOTICE:
                $errors = "Notice";
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $errors = "Warning";
                break;
            case E_ERROR:
            case E_USER_ERROR:
                $errors = "Fatal Error";
                break;
            default:
                $errors = "Unknown Error";
                break;
        }

        if ($this->debug) {
            error_log(sprintf("PHP %s: %s in %s on line %d", $errors, $message, $file, $line));
        }
        //save any error
        if($this->logDeprecated || !$deprecated){
            return $this->onAnyException(new \ErrorException($message, 1, $level, $file, $line));
        } else {
            //silence deprecated errors
        }
    }
823515
protected function connectionErrorHandler($code, $message, $file, $line, $args)
    {
        $this->connectionErrors[] = [
            'code' => $code,
            'message' => $message,
            'file' => $file,
            'line' => $line,
            'args' => $args
        ];
    }
145442
public static function error_php($type, $level, $message, $file, $line){
        self::write_log($message, $type, $file, $line);
        if(error_reporting()){
            include PATHAPP . 'errors-info/error_php.php';
        }
    }
89057
public static function handlePhpError($level, $message, $file, $line)
    {

        // don't want to print suppressed errors
        if (error_reporting() > 0) {
            if (self::$phpErrorCapture) {
                self::$capturedPhpErrors[] = [
                    'message' => $message,
                    'level' => $level,
                    'line' => $line,
                    'file' => $file
                ];
            } else {
                $message = '[PHP Error] ' . $message;
                $message .= ' [line ' . $line . ' of ' . $file . ']';

                switch ($level) {
                    case E_USER_DEPRECATED:
                    case E_DEPRECATED:
                    case E_STRICT:
                    case E_NOTICE:
                    case E_USER_NOTICE:
                        self::log($message, Project::MSG_VERBOSE);
                        break;
                    case E_WARNING:
                    case E_USER_WARNING:
                        self::log($message, Project::MSG_WARN);
                        break;
                    case E_ERROR:
                    case E_USER_ERROR:
                    default:
                        self::log($message, Project::MSG_ERR);
                } // switch
            } // if phpErrorCapture
        } // if not @
    }