React\HttpClient\Request::closeError PHP Method

closeError() public method

public closeError ( Exception $error )
$error Exception
    public function closeError(\Exception $error)
    {
        if (self::STATE_END <= $this->state) {
            return;
        }
        $this->emit('error', array($error, $this));
        $this->close($error);
    }

Usage Example

 /**
  * @param HttpRequest $request
  */
 public function setRequestTimeout(HttpRequest $request)
 {
     if ($this->options['timeout'] > 0) {
         $this->requestTimer = $this->loop->addTimer($this->options['timeout'], function () use($request) {
             $request->closeError(new \Exception('Transaction time out'));
         });
     }
 }