public function testHasNoResponse() { $req = new Request('GET', '/'); $prev = new \Exception(); $e = new ConnectException('foo', $req, $prev, ['foo' => 'bar']); $this->assertSame($req, $e->getRequest()); $this->assertNull($e->getResponse()); $this->assertFalse($e->hasResponse()); $this->assertEquals('foo', $e->getMessage()); $this->assertEquals('bar', $e->getHandlerContext()['foo']); $this->assertSame($prev, $e->getPrevious()); }
/** * Handle various Guzzle exceptions * * @param ConnectException|ClientException $exception Guzzle exception instance * * @return mixed[] $messages Array of errorCodes and messages */ protected function handleExceptions($exception) { $messages = array(); if ($exception instanceof ConnectException || $exception instanceof ClientException) { $messages = ['errorCode' => $exception->getCode(), 'message' => json_decode($exception->getResponseBodySummary($exception->getResponse()), true)['error']]; } else { } return $messages; }