Inheritance: extends MessageDispatchException
 /**
  * @test
  */
 public function it_can_also_wrap_a_normal_exception()
 {
     $pendingCommands = ['dispatchMe', 'tellMe'];
     $prevException = new \Exception('previous');
     $commandDispatchException = CommandDispatchException::wrap($prevException, $pendingCommands);
     $this->assertSame('Command dispatch failed. See previous exception for details.', $commandDispatchException->getMessage());
     $this->assertSame(422, $commandDispatchException->getCode());
     $this->assertSame($prevException, $commandDispatchException->getPrevious());
     $this->assertSame($pendingCommands, $commandDispatchException->getPendingCommands());
 }
Esempio n. 2
0
 /**
  * @param mixed $command
  * @throws CommandDispatchException
  * @return void
  */
 public function dispatch($command)
 {
     $this->commandQueue[] = $command;
     if (!$this->isDispatching) {
         $this->isDispatching = true;
         try {
             while ($command = array_shift($this->commandQueue)) {
                 $this->processCommand($command);
             }
             $this->isDispatching = false;
         } catch (\Exception $e) {
             $this->isDispatching = false;
             throw CommandDispatchException::wrap($e, $this->commandQueue);
         }
     }
 }