Render a View to error

@param int    $type
@param string $message
@param string $file
@param int    $line
@return void
189814
public static function renderError($type, $message, $file, $line)
    {
        if (empty(self::$views['error'])) {
            return null;
        } elseif (preg_match('#allowed\s+memory\s+size\s+of\s+\d+\s+bytes\s+exhausted\s+\(tried\s+to\s+allocate\s+\d+\s+bytes\)#i', $message)) {
            die('<br><strong>Fatal error:</strong> ' . $message . ' in <strong>' . $file . '</strong> on line <strong>' . $line . '</strong>');
        }

        $data = self::details($type, $message, $file, $line);

        if (!headers_sent() && strcasecmp(Request::header('accept'), 'application/json') === 0) {
            ob_start();

            self::unregister();

            Response::cache(0);
            Response::type('application/json');

            echo json_encode($data);

            App::stop(500);
        }

        if (in_array($type, self::$fatal)) {
            View::dispatch();
        }

        self::render(self::$views['error'], $data);
    }
113490
public function errorHandler($code, $message, $file, $line)
    {
        $this->debug->setShowBackTrace(false);
        $this->debug->onUncaughtException(new \ErrorException($message, $code, 0, $file, $line));
    }
71597
public static function errorHandler($code, $message, $file, $line)
    {
        // Determine if this error is one of the enabled ones in php config (php.ini, .htaccess, etc)
        $enabled = (bool) ($code & ini_get('error_reporting'));

        // -- FATAL ERROR
        // throw an Error Exception, to be handled by whatever Exception handling logic is available in this context
        if (in_array($code, array(E_USER_ERROR, E_RECOVERABLE_ERROR, E_WARNING)) && $enabled) {
            throw new ErrorException($message, 0, $code, $file, $line);
        }

        // -- NON-FATAL ERROR/WARNING/NOTICE
        // Log the error if it's enabled, otherwise just ignore it
        else {
            if ($enabled) {
                error_log($message, 0);
                return false; // Make sure this ends up in $php_errormsg, if appropriate
            }
        }
    }
1338524
public function error($type, $message, $field = null, $options = []) {
		// if its an array of message we process them one by one
		if (is_array($message)) {
			foreach ($message as $v) {
				$this->error($type, $v, $field, $options);
			}
			return;
		}
		// generate hash
		if (!empty($options['unique_options_hash'])) {
			$hash = sha1($message . serialize($options));
		} else {
			$hash = sha1($message);
		}
		// i18n
		if (empty($options['skip_i18n'])) {
			$message = i18n(null, $message, $options);
		}
		// set field error
		if (!empty($field)) {
			if ($type == 'reset') {
				unset($this->errors['fields'][$field]);
				// recalculate
				$this->errors['flag_error_in_fields'] = false;
				$this->errors['flag_warning_in_fields'] = false;
				if (!empty($this->errors['fields'])) {
					foreach ($this->errors['fields'] as $k => $v) {
						foreach ($v as $k2 => $v2) {
							if ($k2 == 'danger') $this->errors['flag_error_in_fields'] = true;
							if ($k2 == 'warning') $this->errors['flag_warning_in_fields'] = true;
						}
					}
				}
			} else {
				array_key_set($this->errors, ['fields', $field, $type, $hash], $message);
				// modals
				if (!empty($this->fields[$field])) {
					$container_link = $this->fields[$field]['options']['container_link'];
					if (($this->data[$container_link]['type'] ?? '') == 'modal') {
						$this->misc_settings['errors_in_modal'][$container_link] = $this->data[$container_link]['options']['modal_id'];
					}
				}
				// set special flag that we have error in fields
				if ($type == 'danger') {
					$this->errors['flag_error_in_fields'] = true;
					$this->errors['flag_num_errors']++;
				}
				if ($type == 'warning') {
					$this->errors['flag_warning_in_fields'] = true;
				}
				// format
				if (!empty($options['format'])) {
					array_key_set($this->errors, ['formats', $field, $type], 1);
				}
			}
		} else {
			if ($type == 'reset') {
				$this->errors['general'] = [];
				$_SESSION['numbers']['forms'][$this->options['parent_form_link'] ?? $this->form_link]['messages'] = [];
				return;
			}
			// subforms need to display messages on parent form
			if (!empty($this->options['on_success_refresh_parent']) && !empty($this->options['parent_form_link']) && $type != 'danger') {
				$_SESSION['numbers']['forms'][$this->options['parent_form_link']]['messages'][$type][$hash] = $message;
				$this->misc_settings['form_postponed_messages'] = true;
				return;
			}
			// regular postponed messages
			if (!empty($options['postponed'])) {
				$_SESSION['numbers']['forms'][$this->options['parent_form_link'] ?? $this->form_link]['messages'][$type][$hash] = $message;
				$this->misc_settings['form_postponed_messages'] = true;
				return;
			}
			// regular messages
			$this->errors['general'][$type][$hash] = $message;
			if ($type == 'danger') {
				$this->errors['flag_num_errors']++;
			}
		}
	}
1127712
private function error(OutputInterface $output, $message, $args = array())
    {
        /** @noinspection HtmlUnknownTag */
        $output->writeln('<error>' . sprintf($message, $args) . '</error>');
        exit(0);
    }
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';
        }
    }
667188
public function _message($type, $message)
    {
        $context = $this->_context;

        $cssClasses = isset($this->_cssClasses[$type]) ? $this->_cssClasses[$type] : '';

        $context->messages[] = '<div class="' . $cssClasses . '">' . $message . '</div>' . PHP_EOL;
    }
894100
public static function displayError($code,$message,$file,$line)
    {
        if(YII_DEBUG) {
            echo "<h1>PHP Error [$code]</h1>\n";
            echo "<p>$message ($file:$line)</p>\n";
            echo '<pre>';

            $trace=debug_backtrace();
            // skip the first 3 stacks as they do not tell the error position
            if(count($trace)>3)
                $trace=array_slice($trace,3);
            foreach($trace as $i=>$t) {
                if(!isset($t['file']))
                    $t['file']='unknown';
                if(!isset($t['line']))
                    $t['line']=0;
                if(!isset($t['function']))
                    $t['function']='unknown';
                echo "#$i {$t['file']}({$t['line']}): ";
                if(isset($t['object']) && is_object($t['object']))
                    echo get_class($t['object']).'->';
                echo "{$t['function']}()\n";
            }

            echo '</pre>';
        } else {
            echo "<h1>PHP Error [$code]</h1>\n";
            echo "<p>$message</p>\n";
        }
    }
942642
public function handleErrors($code, $message, $file, $line)
    {
        throw new ErrorException($message, 0, $code, $file, $line);
    }
253722
public function log($message, $type = self::MESSAGE_INFO) {
        $format = [$type == self::MESSAGE_ERROR ? Console::FG_RED : Console::FG_BLUE];
        Console::stdout(Console::ansiFormat($message . PHP_EOL, $format));
    }
575407
public function writeError($line, $check, $message, $level = WARNING) {
		// echo $this->currentPhpFile . " " . $level . " Line:" . $line . " - " . $message . "\n";
		$this->outputFile[$this->currentPhpFile][$line][] = array(
			"level"   => $level,
			"line"    => $line,
			"message" => $message,
			"check"   => $check,
		);
	}
215192
public function error($type, $message)
    {    
        $error = array(
            E_WARNING      => 'Warning',
            E_NOTICE       => 'Notice',
            E_USER_ERROR   => 'Error',
            E_USER_WARNING => 'Warning',
            E_USER_NOTICE  => 'Notice',
        );

        if (isset($error[$type])) {
            $this->error[] = $error[$type].': '.$message;
        }

        return true;
    }
924315
public function handleError($number, $message, $file, $line, array $context)
    {
        // This avoids silenced (@'ed) errors from being reported.
        if (error_reporting()) {
            $message = "PHP error $number: $message\n\tat $file:$line";
            Logger::get()->error($message);
            $this->handleException(new \RuntimeException($message));
        }
    }
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; 
		}
	}
684722
protected function output($message, $type = self::OUTPUT_INFO)
    {
        $output = $this->getOutput();

        if ($output === null) {
            return;
        }

        // Chose color type of message
        switch ($type) {
            case self::OUTPUT_COMMENT:
                $logMethod = 'info';
                $prefix = '<comment>';
                $postfix = '</comment>';
                break;

            case self::OUTPUT_ERROR:
                $logMethod = 'critical';
                $prefix = '<error>';
                $postfix = '</error>';
                break;

            case self::OUTPUT_INFO:
            default:
                $logMethod = 'info';
                $prefix = '<info>';
                $postfix = '</info>';
                break;
        }

        $psrLogBase = self::PSR_LOG_BASE;
        $consoleBase = self::SYMFONY_CONSOLE_BASE;

        if ($output instanceof $psrLogBase) {
            $output->$logMethod($message);

        } else {
            if ($output instanceof $consoleBase) {
                $output->writeln($prefix . $message . $postfix);
            }
        }

    }
186409
protected function handleError($type, $message, $file, $line)
    {
        throw new ResourceException(sprintf(
            '%s: "%s" in %s on line %d',
            $type,
            $message,
            $file,
            $line
        ));
    }
12494
public function addError($message, ...$text): void
    {
        $this->add(self::TYPE_ERROR, $message, ...$text);
    }