Sends error report to developers when error occurs

@param string $title
@param string $msg
@param string $flag_file
425988
public static function sendErrorToDevelopers($title, $msg, $flag_file = '')
    {
        $cfg_email = Configuration::getInstance()->get('site')['email'];

        if (!$flag_file) {
            $flag_file = md5($msg);
        }

        FileSystem::mkDir(DIR_CACHE . 'errors/');
        $file = DIR_CACHE . 'errors/' . $flag_file;

        if (!file_exists($file) || filemtime($file) + 3600 < NOW) {
            touch($file);
            file_put_contents($file, $msg);

            /** @noinspection PhpUsageOfSilenceOperatorInspection */
            /** @noinspection UsageOfSilenceOperatorInspection */
            @mail(CMS_SUPPORT_EMAIL, $title, $msg . "\n\nAuto Error Report " . Constants::ADMIN_CMS_NAME . ".\n\nVisitor:\nIP: " . $_SERVER['REMOTE_ADDR'] . "\nBrowser agent: " . $_SERVER['HTTP_USER_AGENT'] . "\nURL: " . $_SERVER['REQUEST_URI'] . "\nReferer: " . $_SERVER['HTTP_REFERER'] . "\n" . date('d.m.Y H:i:s'), 'From: ' . $cfg_email, '-f ' . $cfg_email);
        }
    }
1170507
private function add_error( $plugin_name, $file, $message ) {
		$error['plugin_name'] = $plugin_name;
		$error['file']        = $file;
		$error['message']     = $message;
		$this->errors[]       = $error;
	}
596154
function error($msg, $section = 'bors', $trace = false, $extra = array())
	{
		static $entered = false;
		if($entered)
			throw new Exception('Reentered logger with '.$msg.' in section '.$section);

		$entered = true;

		try
		{
			$this->logger($section, Logger::ERROR, $trace)->addError($msg, $extra);
		}
		catch(Exception $e)
		{
			echo "Exception while error logging:\n<code><xmp>".$e->getMessage()."</xmp></code>\nFirst error is:\n<xmp>$msg\nin".bors_debug::trace()."</xmp>";
		}

		$entered = false;
	}
715432
public function throwError($msg = 'parse error', $count = null)
    {
        $count = is_null($count) ? $this->count : $count;

        $line = $this->line +
            substr_count(substr($this->buffer, 0, $count), "\n");

        if (!empty($this->sourceName)) {
            $loc = "$this->sourceName on line $line";
        } else {
            $loc = "line: $line";
        }

        // TODO this depends on $this->count
        if ($this->peek("(.*?)(\n|$)", $m, $count)) {
            throw new exception("$msg: failed at `$m[1]` $loc");
        } else {
            throw new exception("$msg: $loc");
        }
    }
598002
protected void error(String msg) {
		System.err.println(CSLToolContext.current().getToolName() + ": " + msg);
	}
942667
private function triggerError($errors, $flags = null)
    {
        // This is triggered with things like file_exists()
        if ($flags & STREAM_URL_STAT_QUIET) {
            return $flags & STREAM_URL_STAT_LINK
                // This is triggered for things like is_link()
                ? $this->formatUrlStat(false)
                : false;
        }

        // This is triggered when doing things like lstat() or stat()
        trigger_error(implode("\n", (array) $errors), E_USER_WARNING);

        return false;
    }
1224883
public function error($msg, Token $token = null, $code = 0)
    {
        $error = new ParserException(
            Translator::gettext($msg),
            $token,
            $code
        );
        parent::error($error);
    }
627364
protected function addError($key, $code, array $arguments = [], $title = '')
    {
        $message = $this->addMessage(Error::class, $key, $code, $arguments, $title);
        $this->result->addError($message);
    }
395781
protected function addMessage($status, $title, $message)
    {
        if (!empty($message) && is_array($message)) {
            $liStyle = 'style="margin-bottom: 0;"';

            $message = '<ul><li ' . $liStyle . '>' . implode('</li><li ' . $liStyle . '>', $message) . '</li></ul>';
        }

        $this->messageList[] = array($status, $title, $message);
    }
1144789
private static void showError(Component parent, String title, String msg) {
    JOptionPane.showMessageDialog(parent, msg, title, JOptionPane.ERROR_MESSAGE);
  }
95055
protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
    {
        if (is_null($url)) {
            $url = $this->request->isAjax() ? '' : 'javascript:history.back(-1);';
        } elseif ('' !== $url && !strpos($url, '://') && 0 !== strpos($url, '/')) {
            $url = $this->request->scheme() . '://' . $this->request->host() . '/' . $url;
        }

        $type = $this->getResponseType();
        $result = [
            'code' => 0,
            'msg'  => $msg,
            'data' => $data,
            'url'  => $url,
            'wait' => $wait,
        ];

        if ('view' == strtolower($type)) {

            $this->assign('code', $result['code']);
            $this->assign('msg', $result['msg']);
            $this->assign('data', $result['data']);
            $this->assign('url', $result['url']);
            $this->assign('wait', $result['wait']);
            $result = $this->display(Config::get('dispatch_error_tmpl'));
        }

        HttpResponse::create($result, $type)->header($header)->send();
    }
691767
protected function showError($title, $messages = '', $output)
    {
        $output->writeln("<error>$title</error>");
        $output->writeln('');
        if (is_array($messages)) {
            foreach ($messages as $message) {
                $output->writeln("<comment>$message</comment>");
            }
            $output->writeln('');
        } elseif ($messages != '') {
            $output->writeln("<comment>$messages</comment>");
            $output->writeln('');
        }
    }
304681
public void error(Object format,Object... msg) {
		if (logger.isErrorEnabled()) {
			// check if the first message contains variables variables
			if (format.toString().contains("{")) {
				logger.error(format.toString(), msg);
			} else {
				logger.error(format.toString().concat(" ").concat(JKStringUtil.concat(msg)));
			}
		}
	}
691988
protected function setError(string $msg)
    {
        $this->error = $msg;
        $lastError = error_get_last();
        if ($lastError !== null) {
            $this->errorDetail = sprintf(
                "'%s' in %s on line %s",
                $lastError['message'],
                $lastError['file'],
                $lastError['line']
            );
        }
    }
837400
public static function showError($type, $errorMsg, $phpMsg = '')
    {
        ob_get_length() && ob_end_clean();

        $title = $type ? $type : 'System';
        echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
 <title>$title</title>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
 <style type="text/css">
 body { background-color: white; color: black; font-size: 9pt/11pt; font-family: "ff-tisa-web-pro-1", "ff-tisa-web-pro-2", "Helvetica Neue", Helvetica, "Lucida Grande", "Hiragino Sans GB", "Microsoft YaHei", \5fae\8f6f\96c5\9ed1, "WenQuanYi Micro Hei", sans-serif;}
 #container {margin: 10px;}
 #message {width: 1024px; color: black;}
 .red {color: red;}
 a:link {font: 9pt/11pt verdana, arial, sans-serif; color: red;}
 a:visited {font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e;}
 h1 {color: #FF0000; font: 18pt "Verdana"; margin-bottom: 0.5em;}
 .bg1 {background-color: #FFFFCC;}
 .bg2 {background-color: #EEEEEE;}
 .table {background: #AAAAAA; font: 11pt Menlo,Consolas,"Lucida Console"}
 .info {
  background: none repeat scroll 0 0 #F3F3F3;
  border: 0px solid #aaaaaa;
  border-radius: 10px 10px 10px 10px;
  color: #000000;
  font-size: 11pt;
  line-height: 160%;
  margin-bottom: 1em;
  padding: 1em;
 }

 .help {
  background: #F3F3F3;
  border-radius: 10px 10px 10px 10px;
  font: 12px verdana, arial, sans-serif;
  text-align: center;
  line-height: 160%;
  padding: 1em;
 }

 .sql {
  background: none repeat scroll 0 0 #FFFFCC;
  border: 1px solid #aaaaaa;
  color: #000000;
  font-family: arial, sans-serif;
  font-size: 9pt;
  line-height: 160%;
  margin-top: 1em;
  padding: 4px;
 }
 </style>
</head>
<body>
<div id="container">
<h1>$title</h1>
<div class='info'>$errorMsg</div>
EOT;
        if (!empty($phpMsg)) {
            $str = '<div class="info">';
            $str .= '<p><strong>tracing</strong></p>';
            if (is_array($phpMsg)) {
                $str .= '<table cellpadding="5" cellspacing="1" width="100%" class="table"><tbody>';
                $str .= '<tr class="bg2"><td>No.</td><td>File</td><td>Line</td><td>Code</td></tr>';
                foreach ($phpMsg as $k => $msg) {
                    $k++;
                    $str .= '<tr class="bg1">';
                    $str .= '<td>' . $k . '</td>';
                    $str .= '<td>' . str_replace(dirname(PSROOT), '..', $msg['file']) . '</td>';
                    $str .= '<td>' . $msg['line'] . '</td>';
                    $str .= '<td>' . $msg['function'] . '</td>';
                    $str .= '</tr>';
                }
                $str .= '</tbody></table>';
            } else {
                $str .= '<ul>' . $phpMsg . '</ul>';
            }
            $str .= '</div>';
            echo $str;
        }
        echo <<<EOT
</div>
</body>
</html>
EOT;
    }
711777
public function sendLinkMsg($title, $text, $picUrl = '', $messageUrl)
    {
        $query = [
            'msgtype' => 'link',
            'link' => [
                'title' => $title,
                'text' => $text,
                'picUrl' => $picUrl,
                'messageUrl' => $messageUrl
            ],
        ];
        return $this->sendMsg($query);
    }
373275
public static function responseError($mdata = array(), $status = null, $msg = null)
    {
        if (!$status) {
            $status = 400;
        }

        if (method_exists($mdata, 'getFile')) {
            $data = [
                "msg" => $msg ?: $mdata->getMessage(),
                "status" => $status,
                "data" => [],
            ];
            if (LEVEL_ENV < 2) {
                $data['data']['file'] = $mdata->getFile();
                $data['data']['line'] = $mdata->getLine();
                $data['data']['code'] = $mdata->getCode();
                $data['data']['debug'] = debug_backtrace();
            }
        } else{
            $data = [
                "msg" => $msg,
                "status" => $status,
                "data" => $mdata,
            ];
        }

        return $data;
    }