Exception.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Copyright (C) Alibaba Cloud Computing
  4. * All rights reserved
  5. */
  6. /**
  7. * The Exception of the log serivce request & response.
  8. *
  9. * @author log service dev
  10. */
  11. class Aliyun_Log_Exception extends Exception{
  12. /**
  13. * @var string
  14. */
  15. private $requestId;
  16. /**
  17. * Aliyun_Log_Exception constructor
  18. *
  19. * @param string $code
  20. * log service error code.
  21. * @param string $message
  22. * detailed information for the exception.
  23. * @param string $requestId
  24. * the request id of the response, '' is set if client error.
  25. */
  26. public function __construct($code, $message, $requestId='') {
  27. parent::__construct($message);
  28. $this->code = $code;
  29. $this->message = $message;
  30. $this->requestId = $requestId;
  31. }
  32. /**
  33. * The __toString() method allows a class to decide how it will react when
  34. * it is treated like a string.
  35. *
  36. * @return string
  37. */
  38. public function __toString() {
  39. return "Aliyun_Log_Exception: \n{\n ErrorCode: $this->code,\n ErrorMessage: $this->message\n RequestId: $this->requestId\n}\n";
  40. }
  41. /**
  42. * Get Aliyun_Log_Exception error code.
  43. *
  44. * @return string
  45. */
  46. public function getErrorCode() {
  47. return $this->code;
  48. }
  49. /**
  50. * Get Aliyun_Log_Exception error message.
  51. *
  52. * @return string
  53. */
  54. public function getErrorMessage() {
  55. return $this->message;
  56. }
  57. /**
  58. * Get log service sever requestid, '' is set if client or Http error.
  59. *
  60. * @return string
  61. */
  62. public function getRequestId() {
  63. return $this->requestId;
  64. }
  65. }