Error.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * QcloudApi_Common_Error
  4. */
  5. class QcloudApi_Common_Error
  6. {
  7. /**
  8. * LOCAL_ERROR_CODE
  9. */
  10. const LOCAL_ERROR_CODE = 3000;
  11. /**
  12. * RESOURCE_PARTLY_FAILED
  13. */
  14. const RESOURCE_PARTLY_FAILED = 5400;
  15. /**
  16. * $_code
  17. * 错误号
  18. */
  19. protected $_code;
  20. /**
  21. * $_message
  22. * 错误信息
  23. */
  24. protected $_message;
  25. /**
  26. * $_ext
  27. * 扩展信息
  28. */
  29. protected $_ext;
  30. /**
  31. * __construct
  32. * @param int $code 错误号
  33. * @param string $message 错误信息
  34. * @param string $ext 扩展信息
  35. */
  36. public function __construct($code, $message, $ext = '')
  37. {
  38. $code = (int) $code;
  39. $this->_code = $code ? $code : self::LOCAL_ERROR_CODE;
  40. $this->_message = $message;
  41. $this->_ext = $ext;
  42. }
  43. /**
  44. * getCode
  45. * 获取错误号
  46. */
  47. public function getCode()
  48. {
  49. return $this->_code;
  50. }
  51. /**
  52. * getMessage
  53. * 获取错误信息
  54. */
  55. public function getMessage()
  56. {
  57. return $this->_message;
  58. }
  59. /**
  60. * getExt
  61. * 获取扩展信息
  62. */
  63. public function getExt()
  64. {
  65. return $this->_ext;
  66. }
  67. }