/**
  * @covers WindowsAzure\Common\ServiceException::getErrorReason
  */
 public function testGetErrorReason()
 {
     // Setup
     $code = '210';
     $error = 'Invalid value provided';
     $reason = 'Value can\'t be null';
     $e = new ServiceException($code, $error, $reason);
     // Test
     $actualErrorReason = $e->getErrorReason();
     // Assert
     $this->assertEquals($reason, $actualErrorReason);
 }
Esempio n. 2
0
 /**
  * Extracts the error code from a service exception
  *
  * @param  ServiceException $exception
  * @return string
  */
 protected function getErrorCodeFromServiceException(ServiceException $exception)
 {
     $xml = @simplexml_load_string($exception->getErrorReason());
     if ($xml && isset($xml->Code)) {
         return (string) $xml->Code;
     }
     return $exception->getErrorReason();
 }