No Description

SetQueueAttributeResponse.php 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace AliyunMNS\Responses;
  3. use AliyunMNS\Constants;
  4. use AliyunMNS\Exception\MnsException;
  5. use AliyunMNS\Exception\QueueNotExistException;
  6. use AliyunMNS\Exception\InvalidArgumentException;
  7. use AliyunMNS\Responses\BaseResponse;
  8. use AliyunMNS\Common\XMLParser;
  9. class SetQueueAttributeResponse extends BaseResponse
  10. {
  11. public function __construct()
  12. {
  13. }
  14. public function parseResponse($statusCode, $content)
  15. {
  16. $this->statusCode = $statusCode;
  17. if ($statusCode == 204) {
  18. $this->succeed = TRUE;
  19. } else {
  20. $this->parseErrorResponse($statusCode, $content);
  21. }
  22. }
  23. public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
  24. {
  25. $this->succeed = FALSE;
  26. $xmlReader = $this->loadXmlContent($content);
  27. try {
  28. $result = XMLParser::parseNormalError($xmlReader);
  29. if ($result['Code'] == Constants::INVALID_ARGUMENT)
  30. {
  31. throw new InvalidArgumentException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  32. }
  33. if ($result['Code'] == Constants::QUEUE_NOT_EXIST)
  34. {
  35. throw new QueueNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  36. }
  37. throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  38. } catch (\Exception $e) {
  39. if ($exception != NULL) {
  40. throw $exception;
  41. } elseif($e instanceof MnsException) {
  42. throw $e;
  43. } else {
  44. throw new MnsException($statusCode, $e->getMessage());
  45. }
  46. } catch (\Throwable $t) {
  47. throw new MnsException($statusCode, $t->getMessage());
  48. }
  49. }
  50. }
  51. ?>