Webmozart\Console\UI\Component\ExceptionTrace::render PHP Method

render() public method

Renders the exception trace.
public render ( IO $io, integer $indentation )
$io Webmozart\Console\Api\IO\IO The I/O.
$indentation integer The number of spaces to indent.
    public function render(IO $io, $indentation = 0)
    {
        if (!$io->isVerbose()) {
            $io->errorLine('fatal: ' . $this->exception->getMessage());
            return;
        }
        $exception = $this->exception;
        $this->renderException($io, $exception);
        if ($io->isVeryVerbose()) {
            while ($exception = $exception->getPrevious()) {
                $io->errorLine('Caused by:');
                $this->renderException($io, $exception);
            }
        }
    }

Usage Example

コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function run(RawArgs $args = null, InputStream $inputStream = null, OutputStream $outputStream = null, OutputStream $errorStream = null)
 {
     // Render errors to the preliminary IO until the final IO is created
     $io = $this->preliminaryIo;
     try {
         if (null === $args) {
             $args = new ArgvArgs();
         }
         $ioFactory = $this->config->getIOFactory();
         if (null === $ioFactory) {
             throw new LogicException('The IO factory must be set.');
         }
         /** @var IO $io */
         $io = call_user_func($ioFactory, $this, $args, $inputStream, $outputStream, $errorStream);
         $resolvedCommand = $this->resolveCommand($args);
         $command = $resolvedCommand->getCommand();
         $parsedArgs = $resolvedCommand->getArgs();
         $statusCode = $command->handle($parsedArgs, $io);
     } catch (Exception $e) {
         if (!$this->config->isExceptionCaught()) {
             throw $e;
         }
         $trace = new ExceptionTrace($e);
         $trace->render($io);
         $statusCode = $this->exceptionToExitCode($e->getCode());
     }
     if ($this->config->isTerminatedAfterRun()) {
         exit($statusCode);
     }
     return $statusCode;
 }
All Usage Examples Of Webmozart\Console\UI\Component\ExceptionTrace::render