当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::renderException方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Application::renderException方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::renderException方法的具体用法?PHP Application::renderException怎么用?PHP Application::renderException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Application的用法示例。


在下文中一共展示了Application::renderException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderException

 /**
  * Renders a caught exception.
  *
  * @param \Exception      $e      An exception instance
  * @param OutputInterface $output An OutputInterface instance
  */
 public function renderException($e, $output = null)
 {
     if (!$output) {
         $output = $this->output;
         if ($output instanceof ConsoleOutputInterface) {
             $output = $output->getErrorOutput();
         }
     }
     return parent::renderException($e, $output);
 }
开发者ID:encorephp,项目名称:console,代码行数:16,代码来源:Application.php

示例2: searchInPackageNames

 /**
  * Search for dependencies in multiple packages.
  *
  * @param string[]           $packageNames The package names.
  * @param ComposerRepository $repository   The repository.
  *
  * @return void
  */
 private function searchInPackageNames($packageNames, ComposerRepository $repository)
 {
     foreach ($packageNames as $packageName) {
         try {
             $packages = $repository->findPackages($packageName);
             $this->searchInPackages($packages);
         } catch (\Exception $e) {
             $this->application->renderException($e, $this->output);
         }
     }
 }
开发者ID:bit3,项目名称:composer-global-depends,代码行数:19,代码来源:DependencyAnalyser.php

示例3: renderException

 /**
  * Passes exception to error handler before rendering to output
  *
  * @param Exception $e
  * @param OutputInterface $output
  * @return void
  */
 public function renderException(Exception $e, OutputInterface $output)
 {
     if ($this->container->has('error_handler')) {
         /** @var \Whoops\RunInterface $run */
         $run = $this->container->get('error_handler');
         // from now on ConsoleApplication will render exception
         $run->allowQuit(false);
         $run->writeToOutput(false);
         // Ignore the return string, parent call will render exception
         $run->handleException($e);
     }
     parent::renderException($e, $output);
 }
开发者ID:abava,项目名称:console,代码行数:20,代码来源:ConsoleApplication.php

示例4: renderException

 /**
  * {@inheritdoc}
  */
 public function renderException(\Exception $e, OutputInterface $output)
 {
     $memory = fopen('php://memory', 'rw');
     $errorStream = new StreamOutput($memory, OutputInterface::VERBOSITY_VERY_VERBOSE, $output ? $output->isDecorated() : null, $output ? $output->getFormatter() : null);
     parent::renderException($e, $errorStream);
     rewind($memory);
     $exception = '';
     while (!feof($memory)) {
         $exception .= fread($memory, 8192);
     }
     fclose($memory);
     $console = new ConsoleOutput();
     $explode = explode("\n", rtrim($exception));
     foreach ($explode as &$line) {
         $line = $console->prefixWithTimestamp($line);
     }
     $output->write(implode("\n", $explode) . "\n");
 }
开发者ID:cawaphp,项目名称:cawa,代码行数:21,代码来源:Application.php

示例5: command

 /**
  * Execute console command using it's name.
  *
  * @param string               $command
  * @param array|InputInterface $parameters
  * @param OutputInterface      $output
  * @return CommandOutput
  * @throws ConsoleException
  */
 public function command($command, $parameters = [], OutputInterface $output = null)
 {
     $input = is_object($parameters) ? $parameters : new ArrayInput(compact('command') + $parameters);
     $output = !empty($output) ? $output : new BufferedOutput();
     $outerOutput = $this->container->replace(OutputInterface::class, $output);
     $outerInput = $this->container->replace(InputInterface::class, $input);
     //Go
     $code = self::CODE_UNDEFINED;
     try {
         $code = $this->application()->find($command)->run($input, $output);
     } catch (\Exception $exception) {
         $this->application->renderException($exception, $output);
     } finally {
         $this->container->restore($outerInput);
         $this->container->restore($outerOutput);
     }
     return new CommandOutput($code, $output);
 }
开发者ID:jwdeitch,项目名称:spiral,代码行数:27,代码来源:ConsoleDispatcher.php

示例6: register

 /**
  * Set the handlers.
  *
  * @param bool $debug
  */
 public static function register($debug = true)
 {
     $errorLevels = error_reporting();
     if ($debug) {
         $errorLevels |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
         Debug\DebugClassLoader::enable();
     }
     if (PHP_SAPI !== 'cli') {
         Debug\ErrorHandler::register()->throwAt($errorLevels, true);
         Debug\ExceptionHandler::register($debug);
     } else {
         $consoleHandler = function (\Exception $e) {
             $app = new Application('Bolt CLI', Version::VERSION);
             $output = new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG);
             $app->renderException($e, $output);
             ob_clean();
         };
         Debug\ExceptionHandler::register($debug)->setHandler($consoleHandler);
     }
 }
开发者ID:bolt,项目名称:bolt,代码行数:25,代码来源:ShutdownHandler.php

示例7: command

 /**
  * Execute console command using it's name.
  *
  * @param string               $command
  * @param array|InputInterface $input
  * @param OutputInterface      $output
  * @return CommandOutput
  * @throws ConsoleException
  */
 public function command($command, $input = [], OutputInterface $output = null)
 {
     if (is_array($input)) {
         $input = new ArrayInput(compact('command') + $input);
     }
     if (empty($output)) {
         $output = new BufferedOutput();
     }
     //todo: do we need input scope?
     $this->openScope($input, $output);
     $code = self::CODE_UNDEFINED;
     try {
         /**
          * Debug: this method creates scope for [[InputInterface]] and [[OutputInterface]].
          */
         $code = $this->application()->find($command)->run($input, $output);
     } catch (\Exception $exception) {
         $this->application->renderException($exception, $output);
     } finally {
         $this->restoreScope();
     }
     return new CommandOutput($code, $output);
 }
开发者ID:vvval,项目名称:spiral,代码行数:32,代码来源:ConsoleDispatcher.php

示例8: renderException

 /**
  * {@inheritDoc}
  */
 public function renderException($exception, $output)
 {
     $io = $this->getIO();
     try {
         $composer = $this->getComposer(false, true);
         if ($composer) {
             $config = $composer->getConfig();
             $minSpaceFree = 1024 * 1024;
             if (($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree || ($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree || ($df = @disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree) {
                 $io->writeError('<error>The disk hosting ' . $dir . ' is full, this may be the cause of the following exception</error>');
             }
         }
     } catch (\Exception $e) {
     }
     if (defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
         $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
         $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>');
     }
     if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
         $io->writeError('<error>The following exception is caused by a lack of memory and not having swap configured</error>');
         $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>');
     }
     if ($output instanceof ConsoleOutputInterface) {
         parent::renderException($exception, $output->getErrorOutput());
     } else {
         parent::renderException($exception, $output);
     }
 }
开发者ID:hanovruslan,项目名称:composer,代码行数:31,代码来源:Application.php

示例9: renderException

 /**
  * {@inheritDoc}
  */
 public function renderException($exception, $output)
 {
     if ($output instanceof ConsoleOutputInterface) {
         parent::renderException($exception, $output->getErrorOutput());
     } else {
         parent::renderException($exception, $output);
     }
 }
开发者ID:consolle,项目名称:framework,代码行数:11,代码来源:Application.php

示例10: renderException

 /**
  * Render the given exception.
  *
  * @param  \Exception  $e
  * @param  \Symfony\Component\Console\Output\OutputInterface  $output
  * @return void
  */
 public function renderException($e, $output)
 {
     // If we have an exception handler instance, we will call that first in case
     // it has some handlers that need to be run first. We will pass "true" as
     // the second parameter to indicate that it's handling a console error.
     if (isset($this->exceptionHandler)) {
         $this->exceptionHandler->handleConsole($e);
     }
     parent::renderException($e, $output);
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:17,代码来源:Application.php

示例11: Application

<?php

date_default_timezone_set('Europe/Paris');
require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php";
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputDefinition;
use Evaneos\Flickr\Api\Command\ImportDirectoryCommand;
$console = new Application('Evaneos CLI', 'v0.1');
$console->setCatchExceptions(false);
$input = new ArgvInput();
$output = new ConsoleOutput();
try {
    $commands = array(new ImportDirectoryCommand('flickr:import'));
    foreach ($commands as $command) {
        $console->add($command);
    }
    $result = $console->run($input, $output);
} catch (Exception $e) {
    $console->renderException($e, $output);
    $output->writeln('<error>' . $e->getTraceAsString() . '</error>');
    exit($e->getCode());
}
return $result;
开发者ID:remievaneos,项目名称:flickr-api,代码行数:27,代码来源:bootstrap.php

示例12: renderException

 /**
  * {@inheritDoc}
  */
 public function renderException($exception, $output)
 {
     try {
         $composer = $this->getComposer(false);
         if ($composer) {
             $config = $composer->getConfig();
             $minSpaceFree = 1024 * 1024;
             if (($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree || ($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree) {
                 $output->writeln('<error>The disk hosting ' . $dir . ' is full, this may be the cause of the following exception</error>');
             }
         }
     } catch (\Exception $e) {
     }
     return parent::renderException($exception, $output);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Application.php

示例13: renderException

 public function renderException($e, $output)
 {
     parent::renderException($e, $output);
     //$this->container->get('ui.shell')->installReadlineCallback();
     $this->container->setParameter('application.exit_code', ResultEvent::ERROR);
 }
开发者ID:phpguard,项目名称:phpguard,代码行数:6,代码来源:Application.php

示例14: renderException

 /**
  * {@inheritdoc}
  */
 public function renderException($e, $output)
 {
     $this->runningCommand = null;
     parent::renderException($e, $output);
 }
开发者ID:ryanhouston,项目名称:Behat,代码行数:8,代码来源:BehatApplication.php

示例15: renderException

 /**
  * Renders a caught exception.
  * @param $e
  */
 public function renderException($e)
 {
     $this->console->renderException($e, new ConsoleOutput());
     die;
 }
开发者ID:dannyweeks,项目名称:mersey,代码行数:9,代码来源:Mersey.php


注:本文中的Symfony\Component\Console\Application::renderException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。