Handle error catch.

@param int $code → error code
@param int $msg  → error message
@param int $file → error file
@param int $line → error line

@return boolean
358781
public function error($code, $msg, $file, $line)
    {
        $type = $this->getErrorType($code);

        $this->setParams($type, $code, $msg, $file, $line, '', 0);

        return $this->render();
    }
723934
public function errorHandler($code, $message, $file = '', $line = '')
    {
        if ($this->error_to_exception) {

            if (ob_get_length() > 0) {
                ob_end_clean(); // Fix templates
            }

            throw new Exception($message);
        }

        $error = array(
            'code' => $code,
            'file' => $file,
            'line' => $line,
            'message' => $message,
            'backtrace' => $this->log_backtrace ? gplcart_backtrace() : array()
        );

        $print = $this->print_error || !$this->isDb();

        if (in_array($code, $this->getFatalErrorTypes())) {

            if ($print) {
                return false; // Let it fall through to the standard PHP error handler
            }

            $this->log('php_shutdown', $error, 'danger', false);
            return true;
        }

        $key = md5(json_encode($error));

        if (isset($this->errors[$key])) {
            return true;
        }

        $this->errors[$key] = $error;

        if ($print) {
            echo $this->getFormattedError($error);
        }

        $this->log('php_error', $error, 'warning', false);
        return true;
    }
1165163
public static function native($code, $error, $file, $line, Logger $logger, $reporting, $exit = true)
    {
        if ($reporting === 0) {
            return;
        }

        // create an ErrorException for the PHP error
        $exception = new \ErrorException($error, $code, 0, $file, $line);

        if (in_array($code, (array)Config::get('error.ignore_levels'))) {
            return static::log($exception, $logger);
        }

        // display the ErrorException
        static::exception($exception, $logger, $exit);
    }
1238370
public function handleError($type, $message, $file, $line, $context)
    {
        if ($this->errorReporting() & $type) {
            $error = new \ErrorException($message, 0, $type, $file, $line);

            if ($this->convertFatalErrors && ($type & (E_RECOVERABLE_ERROR | E_USER_ERROR))) {
                throw $error;
            }

            if ($this->getLoggedErrorTypes() & $type) {
                $this->log($error);
            }
        }
        
        return $this->chainedErrorHandler
            ? call_user_func($this->chainedErrorHandler, $type, $message, $file, $line, $context)
            : false;
    }
795422
public function handleFatalError($code, $message, $file, $line)
    {
        error_log($message, 0);
        $this->handleException(new FatalErrorException($message, 500, $file, $line));

        return true;
    }
1136063
protected function throwException($code, $msg)
    {
        $args = func_get_args();

        $code = array_shift($args);

        throw new \RuntimeException(call_user_func_array('sprintf', $args), $code);
    }
131420
public function triggerError($errorCode, $errorMessage = '')
    {
        $callError = $errorCode;

        if (!isset($this->error[$errorCode]) || !is_callable($this->error[$errorCode])) {
            if (isset($this->error[0]) && is_callable($this->error[0])) {
                $callError = 0;
            } else {
                // Nothing set to handle this error!
                return;
            }
        }

        // Error response function exists
        $this->match = true;

        //call_user_func_array($this->error[$errorCode], array($errorCode, $errorMessage));
        $this->error[$callError]($errorCode, $errorMessage);
        // Or use call_user_func_array ?

        exit($errorCode);
    }
1106290
protected function setError($code, $message)
    {
        $this->error = new \OtherCode\Rest\Core\Error($code, $message);
    }
984119
public function handleError(int $num, string $str, string $file, int $line): void
    {
        $this->handleException(new \ErrorException($str, 0, $num, $file, $line));
        $this->stop(-1);
    }
554295
public static function stop($code, $msg = null)
    {
        Response::status($code, false) && self::trigger('changestatus', array($code, $msg));

        if (self::$state < 4) {
            self::$state = 4;
            self::trigger('finish');
        }

        exit;
    }
390488
public function showError($code, $description = '$'){
        $description = $description == "$" && isset($this->errorMsg[$code]) ? $this->errorMsg[$code] : $description;
        $description .= '['.$code.']';
        throw new Exception($description, 400);
    }
818810
public function handler($number, $message, $file, $line, $context) {

		if(0 === error_reporting()) { 
			return;
		}

		$this -> error = new Error();
		$this -> error -> setFile($file); 
		$this -> error -> setMessage($message); 
		$this -> error -> setNumber($number); 
		$this -> error -> setLine($line); 
		$this -> error -> setDate(new DateTime()); 
		$this -> error -> setContext($context); 
		$this -> error -> setBacktrace(debug_backtrace(null, 5));
		$this -> error -> setIp(Request :: getIp());

		switch($this -> error -> getNumber()) {

			case E_ERROR :
			case E_CORE_ERROR :
			case E_COMPILE_ERROR :
			case E_PARSE :
				$this -> error -> setType('FATAL');
			break;
			
			case E_USER_ERROR :
			case E_RECOVERABLE_ERROR :
				$this -> error -> setType('ERROR');
			break;
		
			case E_WARNING :
			case E_CORE_WARNING :
			case E_COMPILE_WARNING :
			case E_USER_WARNING :
				$this -> error -> setType('WARNING');
			break;
		
			case E_NOTICE :
			case E_USER_NOTICE :
				$this -> error -> setType('INFO');
			break;
			
			case E_STRICT :
				$this -> error -> setType('STRICT');
			break;
		}

		$this -> action();
	}
1268300
public function handle($type, $message, $file, $line)
    {
        if (self::$catch & $type > 0) {
            self::$error = $message;
            return;
        }
        switch ($type) {
            case E_USER_NOTICE:
            case E_USER_DEPRECATED:
            case E_USER_WARNING:
            case E_USER_ERROR:
                $backtrace = debug_backtrace();
                if (isset($backtrace[2]['file'])) {
                    $file = $backtrace[2]['file'];
                }
                if (isset($backtrace[2]['line'])) {
                    $line = $backtrace[2]['line'];
                }
                break;
        }
        switch ($type) {
            case E_USER_ERROR:
            case E_ERROR:
            case E_RECOVERABLE_ERROR:
                throw new ErrorException($message, 0, $type, $file, $line);
            default:
                $this->logger->log($this->map[$type], self::$strings[$type] . ': ' . $message, array(
                    'file' => $file,
                    'line' => $line,
                    'code' => $type
                ));
        }
    }
278041
public function handleError($error, $code, $path, $source, $parameters, $options)
    {
        /* @var \Throwable $error */
        $exception = $options['debug']
            ? $this->getDebuggedException($error, $code, $source, $path, $parameters, $options)
            : $error;

        $handler = $options['error_handler'];
        if (!$handler) {
            // @codeCoverageIgnoreStart
            if ($options['debug'] && $options['exit_on_error']) {
                if ($options['html_error']) {
                    echo $exception->getMessage();
                    exit(1);
                }
                if (!function_exists('xdebug_is_enabled') || !xdebug_is_enabled()) {
                    echo $exception->getMessage()."\n".$exception->getTraceAsString();
                    exit(1);
                }
            }
            // @codeCoverageIgnoreEnd
            throw $exception;
        }

        $handler($exception);
    }
113490
public function errorHandler($code, $message, $file, $line)
    {
        $this->debug->setShowBackTrace(false);
        $this->debug->onUncaughtException(new \ErrorException($message, $code, 0, $file, $line));
    }
708673
public function addError($error, $file = __FILE__, $line = __LINE__, $type = ERROR_INFORMATION, $log = LOG_SYSTEM) {
        if ($log != LOG_HISTORY && $log != LOG_CRONS && $log != LOG_EVENT) {
            if (Config::config()['user']['debug']['log']) {
                if ($log == LOG_SQL) {
                    $error = preg_replace('#([\t]{2,})#isU', "", $error);
                }

                $data = date("d/m/Y H:i:s : ", time()) . '[' . $type . '] file ' . $file . ' / line ' . $line . ' / ' . $error;
                file_put_contents(APP_LOG_PATH . $log . '.log', $data . "\n", FILE_APPEND | LOCK_EX);

                if ((Config::config()['user']['debug']['error']['error'] && $type == ERROR_FATAL) || (Config::config()['user']['debug']['error']['exception'] == true && $type == ERROR_EXCEPTION) || preg_match('#Exception#isU', $type) || (Config::config()['user']['debug']['error']['fatal'] == true && $type == ERROR_ERROR)) {
                    if (CONSOLE_ENABLED == MODE_HTTP) {
                        echo $data . "\n<br />";
                    }
                    else {
                        echo $data . "\n";
                    }
                }
            }
        }
        else {
            file_put_contents(APP_LOG_PATH . $log . '.log', $error . "\n", FILE_APPEND | LOCK_EX);
        }
    }
442143
protected function _error($message, $code)
    {
        header("HTTP/1.0 {$code} {$message}");
        echo $message;

        TableRegistry::get('Field.FieldInstances')->connection()->disconnect();
        exit(0);
    }