public function testAddsUserAgentIfAvailable()
 {
     $response = new Response(200);
     $response->setRequest(new Request('GET', 'http://www.foo.com', array('User-Agent' => 'Foo/Bar')));
     $e = new ServiceResponseException('Foo!');
     $e->setExceptionCode('foo');
     $e->setExceptionType('client');
     $e->setRequestId('xyz');
     $e->setResponse($response);
     $this->assertEquals('Aws\\Common\\Exception\\ServiceResponseException: AWS Error Code: foo, Status Code: 200, AWS Request ID: xyz, AWS Error Type: client, AWS Error Message: Foo!, User-Agent: Foo/Bar', (string) $e);
 }
 public function testRepresentsException()
 {
     $e = new ServiceResponseException('Foo!');
     $e->setExceptionCode('foo');
     $this->assertEquals('foo', $e->getExceptionCode());
     $e->setExceptionType('client');
     $this->assertEquals('client', $e->getExceptionType());
     $e->setRequestId('xyz');
     $this->assertEquals('xyz', $e->getRequestId());
     $response = new Response(200);
     $e->setResponse($response);
     $this->assertSame($response, $e->getResponse());
     $this->assertEquals('Aws\\Common\\Exception\\ServiceResponseException: AWS Error Code: foo, Status Code: 200, AWS Request ID: xyz, AWS Error Type: client, AWS Error Message: Foo!', (string) $e);
 }
示例#3
0
 /**
  * Check if an exception satisfies a success or failure acceptor
  *
  * @param ServiceResponseException $e
  *
  * @return bool|null Returns true for success, false for failure, and null for no transition
  */
 protected function checkErrorAcceptor(ServiceResponseException $e)
 {
     if ($this->waiterConfig->get(WaiterConfig::SUCCESS_TYPE) == 'error') {
         if ($e->getExceptionCode() == $this->waiterConfig->get(WaiterConfig::SUCCESS_VALUE)) {
             // Mark as a success
             return true;
         }
     }
     // Mark as an attempt
     return null;
 }