Example #1
0
 /**
  *
  * {@inheritdoc}
  *
  * @throws InvalidArgumentException if there is no exception to throw.
  * @throws ThrowUpException because what else do you expect it to do?
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($name = $input->getArgument('exception')) {
         $orig = $this->context->get(preg_replace('/^\\$/', '', $name));
     } else {
         $orig = $this->context->getLastException();
     }
     if (!$orig instanceof \Exception) {
         throw new \InvalidArgumentException('throw-up can only throw Exceptions');
     }
     throw new ThrowUpException($orig);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $incredulity = implode('', $input->getArgument('incredulity'));
     if (strlen(preg_replace('/[\\?!]/', '', $incredulity))) {
         throw new \InvalidArgumentException('Incredulity must include only "?" and "!".');
     }
     $exception = $this->context->getLastException();
     $count = $input->getOption('verbose') ? PHP_INT_MAX : pow(2, max(0, strlen($incredulity) - 1));
     $trace = $this->getBacktrace($exception, $count);
     $shell = $this->getApplication();
     $output->page(function ($output) use($exception, $trace, $shell) {
         $shell->renderException($exception, $output);
         $output->writeln('--');
         $output->write($trace, true, ShellOutput::NUMBER_LINES);
     });
 }