No Description

DeleteMessageResponse.php 2.2KB

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