StackFormation\Helper\Exception::refineException PHP Метод

refineException() публичный статический Метод

public static refineException ( Aws\CloudFormation\Exception\CloudFormationException $exception )
$exception Aws\CloudFormation\Exception\CloudFormationException
    public static function refineException(\Aws\CloudFormation\Exception\CloudFormationException $exception)
    {
        $message = self::extractMessage($exception);
        $matches = [];
        if (preg_match('/^Stack \\[(.+)\\] does not exist$/', $message, $matches)) {
            return new \StackFormation\Exception\StackNotFoundException($matches[1], $exception);
        }
        if (preg_match('/.+stack\\/(.+)\\/.+is in ([A-Z_]+) state and can not be updated./', $message, $matches)) {
            return new \StackFormation\Exception\StackCannotBeUpdatedException($matches[1], $matches[2], $exception);
        }
        if (strpos($message, 'No updates are to be performed.') !== false) {
            return new \StackFormation\Exception\StackNoUpdatesToBePerformedException('TBD');
        }
        return new \StackFormation\Exception\CleanCloudFormationException($message, 0, $exception);
    }

Usage Example

Пример #1
0
 public function observeStackActivity($pollInterval = 20)
 {
     $eventTable = new StackEventsTable($this->output);
     $lastStatus = Poller::poll(function () use($eventTable) {
         try {
             try {
                 $this->stack = $this->stackFactory->getStack($this->stack->getName(), true);
                 // load fresh instance for updated status
                 $this->output->writeln("-> Polling... (Stack Status: {$this->stack->getStatus()})");
                 $eventTable->renderEvents($this->stack->getEvents());
             } catch (CloudFormationException $exception) {
                 throw Exception::refineException($exception);
             }
         } catch (StackNotFoundException $exception) {
             $this->output->writeln("-> Stack gone.");
             return Stack::STATUS_STACK_GONE;
             // this is != false and will stop the poller
         }
         return $this->stack->isInProgress() ? false : $this->stack->getStatus();
     }, $pollInterval, 1000);
     $this->printStatus($lastStatus);
     $this->printResources();
     $this->printOutputs();
     return $lastStatus;
 }
All Usage Examples Of StackFormation\Helper\Exception::refineException