isExceptionCaught() public method

Returns whether the application catches and displays exceptions thrown while running a command.
See also: setCatchExceptions()
public isExceptionCaught ( ) : boolean
return boolean Returns `true` if exceptions are caught and `false` otherwise.
示例#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;
 }
 public function testSetCatchExceptions()
 {
     $this->config->setCatchExceptions(true);
     $this->assertTrue($this->config->isExceptionCaught());
     $this->config->setCatchExceptions(false);
     $this->assertFalse($this->config->isExceptionCaught());
 }