fail() public method

Marks the observable as complete with the given error.
public fail ( Throwable $exception )
$exception Throwable
示例#1
0
 /**
  * {@inheritdoc}
  */
 public function dispose(Throwable $exception = null)
 {
     if (null === $exception) {
         $exception = new DisposedException();
     }
     $this->emitter = null;
     if (null === $this->coroutine) {
         $this->queue->fail($exception);
         return;
     }
     if (null !== $this->onDisposed) {
         try {
             $result = ($this->onDisposed)($exception);
             if ($result instanceof Generator) {
                 $awaitable = new Coroutine($result);
             } else {
                 $awaitable = resolve($result);
             }
             $awaitable = $awaitable->then(function () use($exception) {
                 throw $exception;
             });
         } catch (Throwable $exception) {
             $awaitable = reject($exception);
         }
     } else {
         $awaitable = reject($exception);
     }
     $awaitable->done(null, [$this->coroutine, 'cancel']);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function dispose(Throwable $exception = null)
 {
     if (null === $exception) {
         $exception = new DisposedException('Observable disposed.');
     }
     $this->emitter = null;
     $this->queue->fail($exception);
     if (null !== $this->coroutine) {
         $this->coroutine->cancel($exception);
     }
 }