Render auto complete alternatives.

@param   string                    $wrongName  The wrong command name to auto completed.
@param   CommandNotFoundException  $exception  The exception of wrong argument.

@return  void

@since   1.0
776449
public function renderAlternatives($wrongName, $exception)
	{
		/** @var $exception \InvalidArgumentException */
		$message      = $exception->getMessage();
		$autoComplete = '';
		$alternatives = array();

		// Autocomplete
		foreach ($this->children as $command)
		{
			/** @var $command Command */
			$commandName = $command->getName();

			/*
			 * Here we use "Levenshtein distance" to compare wrong name with every command names.
			 *
			 * If the difference number less than 1/3 of wrong name which user typed, means this is a similar name,
			 * we can notice user to choose these similar names.
			 *
			 * And if the string of wrong name can be found in a command name, we also notice user to choose it.
			 */
			if (levenshtein($wrongName, $commandName) <= (strlen($wrongName) / 3) || strpos($commandName, $wrongName) !== false)
			{
				$alternatives[] = "    " . $commandName;
			}
		}

		if (count($alternatives))
		{
			$autoComplete = "Did you mean one of these?\n";
			$autoComplete .= implode($alternatives);
		}

		$this->out('');
		$this->err("<error>{$message}</error>");
		$this->out('');
		$this->err($autoComplete);
	}
1158338
public function notFoundHttpException(NotFoundHttpException $exception)
    {
        $statuCode = $exception->getStatusCode();
        $error = [[
            'status' => $statuCode,
            'code'   => $this->getCode('not_found_http'),
            'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()],
            'title'  => $this->getDescription($exception),
            'detail' => $this->getNotFoundMessage($exception),
        ]];

        $this->jsonApiResponse->setStatus($statuCode);
        $this->jsonApiResponse->setErrors($error);
    }
1201514
protected function handle($exception)
  {
    Output::error($exception);

    if ($this->isAjax()) {
      $this->toJson($exception);
      return;
    }

    $this->toHtml($exception);
  }
284367
public function getCommand($serverName, $commandName)
    {
        $index = $serverName . '::' . $commandName;
        if (!array_key_exists($index, $this->commands)) {
            if (!in_array($serverName, $this->servers)) {
                throw new MissingServerException($serverName);
            }

            throw new MissingCommandException($serverName, $commandName);
        }

        return $this->commands[$index];
    }
335505
protected function renderException($output, \Exception $e)
    {
        $this->app[ExceptionHandler::class]->renderForConsole($output, $e);
    }
168640
public function renderException(\Exception $exception)
    {
        $verbose = $this->console ? $this->console->get('verbose', 0) : 0;

        if (!$verbose) {
            $this->out()->err($exception->getMessage());

            return;
        }

        /** @var $exception \Exception */
        $class = get_class($exception);

        // @codingStandardsIgnoreStart
        $output = <<<EOF
<error>Exception '{$class}' with message:</error> <fg=cyan;options=bold>{$exception->getMessage()}</fg=cyan;options=bold>
<info>in {$exception->getFile()}:{$exception->getLine()}</info>

<error>Stack trace:</error>
{$exception->getTraceAsString()}
EOF;
        // @codingStandardsIgnoreEnd

        $this->out('');
        $this->err($output);
    }
54474
public function setOption($optionName, $value)
    {
        if (!array_key_exists($optionName, $this->supportedOptions)) {
            throw new Exception(sprintf('The view option "%s" you\'re trying to set doesn\'t exist in class "%s".', $optionName, get_class($this)), 1359625876);
        }

        $this->options[$optionName] = $value;
    }
789080
public static function rename(String $oldName, String $newName) : Bool
    {
        $oldName = Info::rpath($oldName);

        if( ! file_exists($oldName) )
        {
            throw new Exception\FileNotFoundException(NULL, $oldName);
        }

        return rename($oldName, $newName);
    }
996557
public function render($request, Exception $exception)
	{
		return Exceptum::render($request, $exception) ?? parent::render($request, $exception);
	}
1181563
protected function renderHtmlErrorMessage(Exception $exception)
    {
        $title = 'Slim Application Error';

        if ($this->displayErrorDetails) {
            $html = '<p>The application could not run because of the following error:</p>';
            $html .= '<h2>Details</h2>';
            $html .= $this->renderHtmlException($exception);

            while ($exception = $exception->getPrevious()) {
                $html .= '<h2>Previous exception</h2>';
                $html .= $this->renderHtmlExceptionOrError($exception);
            }
        } else {
            $html = '<p>A website error has occurred. Sorry for the temporary inconvenience.</p>';
        }

        $output = sprintf(
            "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
            "<title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana," .
            "sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{" .
            "display:inline-block;width:65px;}</style></head><body><h1>%s</h1>%s</body></html>",
            $title,
            $title,
            $html
        );

        return $output;
    }
103905
public function fire(Command $command)
    {
        if (! $this->finder->isFile('.env')) {
            throw new Exception('SocietyCMS is not installed. Please run "php artisan society:install" first.');
        }

        if ($command->option('refresh') && ! App::environment('demo')) {
            throw new Exception('Refresh option is only available in demo mode.');
        }

        if (! $command->option('force') && ! $command->option('refresh')) {
            if (! $command->confirm('Are you sure you want to start Demo Mode?')) {
                throw new Exception('Demo Mode cancelled');
            }
        }
    }
649844
public function render($request, Exception $e)
	{
		if ($this->isHttpException($e))
		{
			return $this->renderHttpException($e);
		}
		else
		{
			return parent::render($request, $e);
		}
	}
688529
public function executeSplit()
    {
        $command = $this->getCommand();
        $process = new Process($command);
        $process->setTimeout(null);
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \Exception($process->getOutput(), 1);
        }

        $this->renameSplitFiles();
    }
17637
public function render($controllerName)
    {
        $controller = $this->getControllerName($controllerName);
        if (null === $controller) {
            throw new ControllerNotFoundException(sprintf('Could not find controller "%s".', $controllerName));
        }

        $route = $this->getRoute($controller);
        if (null === $route) {
            throw new RouteNotFoundException(sprintf('Could not find route for controller "%s".', $controllerName));
        }

        $this->routeRenderer->render($route[1], $route[0]);
    }
1275645
protected function outputError($errorNumber, TestInterface $test, $exception)
    {
        $this->output->writeln(sprintf("  %d)%s:", $errorNumber, $test->getTitle()));

        $message = sprintf("     %s", str_replace(PHP_EOL, PHP_EOL . "     ", $exception->getMessage()));
        $this->output->writeln($this->color('error', $message));

        $location = sprintf('     at %s:%d', $exception->getFile(), $exception->getLine());
        $this->output->writeln($location);

        $this->outputTrace($exception->getTrace());
    }
1265818
protected function processTwig(Exception $exception)
    {
        // Must be a Twig related exception
        if (!$exception instanceof Twig_Error) {
            return false;
        }

        $this->message = $exception->getRawMessage();
        $this->line = $exception->getTemplateLine();

        // Find where the twig markup section begins
        $offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
        $this->line += $offsetArray['markup'];

        // Account for line 0
        $this->line--;

        return true;
    }
667617
public function render($templateName = null)
    {
        if ($templateName === null) {
            throw new InvalidArgumentException(
                'An template name is required and will be search relative from configured templates path'
            );
        }
        $this->setTemplateName($templateName);

        return parent::render($templateName);
    }