Shows the scripts help info with optional error message
@param string $msg
@param int $code The exit code
968853
protected function showHelp($msg = '', $code = 0)
    {
        $usage = Cli::color('USAGE:', 'brown');
        $commands = Cli::color('COMMANDS:', 'brown');
        $sOptions = Cli::color('SPECIAL OPTIONS:', 'brown');
        $pOptions = Cli::color('PUBLIC OPTIONS:', 'brown');
        $version = Cli::color(self::VERSION, 'green');
        $script = $this->getScript();

        if ($msg) {
            $code = $code ?: self::CODE_UNKNOWN_ERROR;
            echo Cli::color('ERROR:', 'light_red') . "\n  " . wordwrap($msg, 108, "\n  ") . "\n\n";
        }

        echo <<<EOF
Gearman worker manager(gwm) script tool. Version $version(lite)

$usage
  $script {COMMAND} -c CONFIG [-v LEVEL] [-l LOG_FILE] [-d] [-w] [-p PID_FILE]
  $script -h
  $script -D

$commands
  start             Start gearman worker manager(default)
  stop              Stop running's gearman worker manager
  restart           Restart running's gearman worker manager
  reload            Reload all running workers of the manager
  status            Get gearman worker manager runtime status

$sOptions
  start/restart
    -d,--daemon        Daemon, detach and run in the background
       --tasks         Only register the assigned tasks, multi task name separated by commas(',')
       --no-test       Not add test handler, when task name prefix is 'test'.(eg: test_task)

  status
    --cmd COMMAND      Send command when connect to the task server. allow:status,workers.(default:status)
    --watch-status     Watch status command, will auto refresh status.

$pOptions
  -c CONFIG          Load a custom worker manager configuration file
  -s HOST[:PORT]     Connect to server HOST and optional PORT, multi server separated by commas(',')

  -n NUMBER          Start NUMBER workers that do all tasks

  -l LOG_FILE        Log output to LOG_FILE or use keyword 'syslog' for syslog support
  -p PID_FILE        File to write master process ID out to

  -r NUMBER          Maximum run task iterations per worker
  -x SECONDS         Maximum seconds for a worker to live
  -t SECONDS         Number of seconds gearmand server should wait for a worker to complete work before timing out

  -v [LEVEL]         Increase verbosity level by one. eg: -v vv | -v vvv

  -h,--help          Shows this help information
  -V,--version       Display the version of the manager
  -D,--dump [all]    Parse the command line and config file then dump it to the screen and exit.\n\n
EOF;
        $this->quit($code);
    }
446125
public function setSuccess($msg, $code = 0)
    {
        $this->data['success'] = true;
        $this->data['code']    = $code;
        $this->data['message'] = $msg;
        
        return $this;
    }
291696
public static function output($data = null, $msg = '', $code = 0)
    {
        if (!$code) {
            echo json_encode([
                'code' => 0,
                'msg' => $msg,
                'data' => $data,
            ], JSON_UNESCAPED_UNICODE);
        } else {
            echo json_encode([
                'code' => $code,
                'msg' => $msg ? $msg : '未知错误',
            ], JSON_UNESCAPED_UNICODE);
        }
    }
1061201
public function error(ServerRequestInterface $request, int $code = 0, string $msg = null, ...$args): ServerRequestInterface
    {
        $routing = $request->getAttribute('routing');

        if (empty($routing)) {
            return $request;
        }

        if ($msg !== null && $args !== []) {
            $msg = \sprintf($msg, ...$args);
        }

        $error = new ActionError($msg, $code);
        $forwardTo = $error->getForwardTo();
        $forwardTo['handler'] += $this->app->getRealHandler($routing['handler']);;

        return $request->withAttribute('routing', $forwardTo);
    }
270481
protected function show_message($msg, $error = false){
		add_action("admin_notices", function() use($msg, $error){
			printf('<div class="%s"><p>%s</p></div>', $error ? 'error' : 'updated', esc_html($msg) );
		});
	}
728739
public function throwError($msg)
    {
        if ($this->ignoreErrors) {
            return;
        }

        if (func_num_args() > 1) {
            $msg = call_user_func_array('sprintf', func_get_args());
        }

        $line = $this->sourceLine;
        $loc = isset($this->sourceNames[$this->sourceIndex]) ? $this->sourceNames[$this->sourceIndex] . " on line $line" : "line: $line";
        $msg = "$msg: $loc";

        if ($this->callStack) {
            $msg .= "\nCall Stack:\n";
            $ncall = 0;

            foreach (array_reverse($this->callStack) as $call) {
                $msg .= "#" . $ncall++ . " " . $call['n'] . " ";
                $msg .= (isset($this->sourceNames[$call[Parser::SOURCE_INDEX]]) ? $this->sourceNames[$call[Parser::SOURCE_INDEX]] : '(unknown file)');
                $msg .= " on line " . $call[Parser::SOURCE_LINE] . "\n";
            }
        }

        throw new CompilerException($msg);
    }
918942
protected static function output_msg($msg) {
        global $CFG, $PAGE;

        // If we are using the web interface we want pretty messages.
        if (!CLI_SCRIPT) {

            $renderer = $PAGE->get_renderer('tool_behat');
            echo $renderer->render_error($msg);

            // Stopping execution.
            exit(1);

        } else {

            // We continue execution after this.
            $clibehaterrorstr = "Ensure you set \$CFG->behat_* vars in config.php " .
                "and you ran admin/tool/behat/cli/init.php.\n" .
                "More info in " . self::DOCS_URL;

            echo 'Error: ' . $msg . "\n\n" . $clibehaterrorstr;
        }
    }
942985
protected function showError($msg = null)
    {
        if ($msg === null) {
            $msg = 'Sitemap is not available, please check your configuration';
        }

        header('HTTP/1.0 503 Service Unavailable');
        $GLOBALS['TSFE']->pageErrorHandler(true, null, $msg);
        exit;
    }
487724
public static function fail($code = '', $message = '', $errors = [], $extras = [])
    {
        return self::loadResult(self::FAIL, $code, $message, $errors, $extras);
    }
333725
public function displayConsole(string $code, string $message)
    {
        $str_additionnal = "\n\n";
        if ($this->type_error != null) {
            $str_additionnal .= " \nPHP Error type : ".$this->type_error;
        }
        if ($this->file_error != null) {
            $str_additionnal .= " \nFile : ".$this->file_error;
        }
        if ($this->line_error != null) {
            $str_additionnal .= " \nLine : ".$this->line_error;
        }

        \iumioFramework\Core\Additional\Manager\Display\OutputManager::displayAsError(
            "An exception was generated\n\nUidie : ".
            $this->uidie."\nTime : ". $this->time."\nType : ".
            $this->code." ".$this->codeTitle."\nEnv : ".
            $this->env."\nExplain : ". $this->explain.
            " \nSolution : ".$this->solution.$str_additionnal
        );

        exit(1);
    }
1269166
protected function error($code, lang_string $message) {
        if (array_key_exists($code, $this->errors)) {
            throw new coding_exception('Error code already defined');
        }
        $this->errors[$code] = $message;
    }
1289947
def send_error_msgtxt(self, code, message, headers=None):
        ""
        if headers is None:
            headers = {}

        if isinstance(message, (list, tuple)):
            message = ''.join(message)
        elif isinstance(message, dict):
            message = repr(message)

        self.send_error_explain(code,
                                ''.join(("<pre>\n", cgi.escape(message), "</pre>\n")),
                                headers,
                                "text/html")
1347159
protected function _respondToError($errorMessage, $httpCode) {
        $this->_setHttpStatusCode($httpCode);
        $this->view->result = array(
            'success' => false,
            'errorMessage' => $errorMessage
        );
    }
295286
public function error($msg, $data = NULL) {
        if (!$this->isAllowToLog(static::LOG_LEVEL_ERROR)) {
            return;
        }

        $this->log('error', $msg, $data);
    }
388172
private function showErrorMsg(int $httpCode, int $errorCode, string $errorType, string $message, array $traceArr, string $file, int $line)
    {
        if (empty($traceArr)) {
            $traceArr = debug_backtrace();
        }
        $content = $this->getErrContent();
        $mainTitle = 'HTTP 错误 ' . $httpCode;
        $errmsgPrefix = '<span style="color:red;">[' . $errorType . ']</span>[' . $errorCode . '] ';
        $errFile = '<span style="color:red;">[file]</span> ' . $file . ' on line <b>' . $line . '</b>';
        $showSource = Application::$app->config->getValue('ERROR_HANDLER_SHOW_SOURCE');
        $mainSource = '';
        $showMainSourceFn = 'javascript:void(0);';
        if ($showSource) {
            $mainSource = 'filesArr.push(' . json_encode($file) . ');
linesArr.push(' . $line . ');
contentArr.push(' . json_encode(htmlspecialchars(file_get_contents($file))) . ');';
            $showMainSourceFn = 'show_source_main();';
        }
        $content = str_replace([
            '{mainTitle}',
            '{errMsg}',
            '{errFile}',
            '{errTrace}',
            '{prettify.css}',
            '{prettify.js}',
            '{main_source}',
            '{showMainSourceFn}'
        ], [
            $mainTitle,
            $errmsgPrefix . htmlspecialchars($message),
            $errFile,
            $this->getTableHtml($traceArr),
            $showSource ? file_get_contents(Application::$app->mvcSourcePath . '/../static/prettify.css') : '',
            $showSource ? file_get_contents(Application::$app->mvcSourcePath . '/../static/prettify.js') : '',
            $mainSource,
            $showMainSourceFn
        ], $content);
        $actionResult = new ContentResult($content);
        $actionResult->statusCode = $httpCode;
        $actionResult->executeResult();
        exit();
    }
441155
public function error($message, $code = 1)
    {
        $this->logger->error($message);

        $this->write($message, self::FC_RED);
        $this->write(PHP_EOL);

        return $code;
    }
860459
public function log($message, $code = self::INFO) {
		$this->adapter->log($code, $message);
	}