本文整理汇总了PHP中Symfony\Component\Console\Event\ConsoleExceptionEvent::getOutput方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleExceptionEvent::getOutput方法的具体用法?PHP ConsoleExceptionEvent::getOutput怎么用?PHP ConsoleExceptionEvent::getOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Event\ConsoleExceptionEvent
的用法示例。
在下文中一共展示了ConsoleExceptionEvent::getOutput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onConsoleException
public function onConsoleException(ConsoleExceptionEvent $event)
{
$exception = $event->getException();
//This listener only wants to deal with this particular Exception
if (!$exception instanceof \GoCardless\Enterprise\Exceptions\ApiException) {
return;
}
$output = $event->getOutput();
$rawReasonPhrase = $exception->getReasonPhrase();
$data = json_decode($rawReasonPhrase, true);
$exceptionName = get_class($exception);
$gocardlessErrorMessage = isset($data['error']['message']) ? $data['error']['message'] : 'No Gocardless error available';
$fieldErrors = isset($data['error']['errors']) ? $data['error']['errors'] : array();
$output->writeln("");
$output->writeln("Exception: {$exceptionName}");
$output->writeln("---------");
$output->writeln("Gocardless error message: {$gocardlessErrorMessage}");
if ($fieldErrors) {
$output->writeln("");
$output->writeln("Field Specific error messages");
}
foreach ($fieldErrors as $error) {
$output->writeln("");
foreach ($error as $k => $e) {
$output->writeln("{$k}: {$e}");
}
$output->writeln("-----------");
}
$output->writeln("LOOK ABOVE FOR MORE INFORMATION ABOUT THIS EXCEPTION");
}
示例2: onConsoleError
/**
* @param ConsoleExceptionEvent $event
*/
public function onConsoleError(ConsoleExceptionEvent $event)
{
$exception = $event->getException();
$command = $event->getCommand();
$output = $event->getOutput();
$this->logger->error(sprintf("error while executing %s -> %s", $command->getName(), $exception->getMessage()));
if ($this->config->get("common/debug")) {
return;
}
$output->writeln(sprintf("error while executing %s -> %s", $command->getName(), $exception->getMessage()));
}
示例3: onConsoleException
/**
* @param \Symfony\Component\Console\Event\ConsoleExceptionEvent $event
*/
public function onConsoleException(ConsoleExceptionEvent $event)
{
$this->campfire->notifyOnConsoleException($event->getInput(), $event->getOutput(), $event->getException(), $event->getExitCode());
}